@@ -51,37 +51,41 @@ export default createOnyxDerivedValueConfig({
5151 isFullyComputed = false ;
5252 }
5353
54+ // if we already computed the report attributes and there is no new reports data, return the current value
55+ if ( ( isFullyComputed && ! sourceValues ) || ! reports ) {
56+ return currentValue ?? { reports : { } , locale : null } ;
57+ }
58+
5459 const reportUpdates = sourceValues ?. [ ONYXKEYS . COLLECTION . REPORT ] ?? { } ;
5560 const reportMetadataUpdates = sourceValues ?. [ ONYXKEYS . COLLECTION . REPORT_METADATA ] ?? { } ;
5661 const reportActionsUpdates = sourceValues ?. [ ONYXKEYS . COLLECTION . REPORT_ACTIONS ] ?? { } ;
5762 const reportNameValuePairsUpdates = sourceValues ?. [ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS ] ?? { } ;
5863 const transactionsUpdates = sourceValues ?. [ ONYXKEYS . COLLECTION . TRANSACTION ] ;
5964 const transactionViolationsUpdates = sourceValues ?. [ ONYXKEYS . COLLECTION . TRANSACTION_VIOLATIONS ] ;
60- // if we already computed the report attributes and there is no new reports data, return the current value
61- if ( ( isFullyComputed && ! sourceValues ) || ! reports ) {
62- return currentValue ?? { reports : { } , locale : null } ;
63- }
6465
6566 let dataToIterate = Object . keys ( reports ) ;
6667 // check if there are any report-related updates
6768
68- const reportUpdatesRelatedToReportActions : string [ ] = [ ] ;
69+ const reportUpdatesRelatedToReportActions = new Set < string > ( ) ;
70+
71+ for ( const actions of Object . values ( reportActionsUpdates ) ) {
72+ if ( ! actions ) {
73+ continue ;
74+ }
6975
70- Object . keys ( reportActionsUpdates ) . forEach ( ( reportKey ) => {
71- Object . keys ( reportActionsUpdates [ reportKey ] ?? { } ) . forEach ( ( reportActionKey ) => {
72- const reportAction = reportActions ?. [ reportKey ] ?. [ reportActionKey ] ;
76+ for ( const reportAction of Object . values ( actions ) ) {
7377 if ( reportAction ?. childReportID ) {
74- reportUpdatesRelatedToReportActions . push ( `${ ONYXKEYS . COLLECTION . REPORT } ${ reportAction . childReportID } ` ) ;
78+ reportUpdatesRelatedToReportActions . add ( `${ ONYXKEYS . COLLECTION . REPORT } ${ reportAction . childReportID } ` ) ;
7579 }
76- } ) ;
77- } ) ;
80+ }
81+ }
7882
7983 const updates = [
8084 ...Object . keys ( reportUpdates ) ,
8185 ...Object . keys ( reportMetadataUpdates ) ,
8286 ...Object . keys ( reportActionsUpdates ) ,
8387 ...Object . keys ( reportNameValuePairsUpdates ) ,
84- ...reportUpdatesRelatedToReportActions ,
88+ ...Array . from ( reportUpdatesRelatedToReportActions ) ,
8589 ] ;
8690
8791 if ( isFullyComputed ) {
0 commit comments