@@ -50,6 +50,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) {
5050 const [ reportAttributes ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES , { canBeMissing : true } ) ;
5151 const prevReportAttributesLocale = usePrevious ( reportAttributes ?. locale ) ;
5252 const [ reports , { sourceValue : changedReports } ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT , { canBeMissing : true } ) ;
53+ const prevReports = usePrevious ( reports ) ;
5354 const [ , { sourceValue : changedReportActions } ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT_ACTIONS , { canBeMissing : true } ) ;
5455 const personalDetails = usePersonalDetails ( ) ;
5556 const prevPersonalDetails = usePrevious ( personalDetails ) ;
@@ -88,14 +89,17 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) {
8889 } , [ prevReportAttributesLocale , loadOptions , reportAttributes ?. locale ] ) ;
8990
9091 const changedReportsEntries = useMemo ( ( ) => {
91- const result : OnyxCollection < OnyxEntry < Report > > = { } ;
92+ const result : OnyxCollection < OnyxEntry < Report > | null > = { } ;
9293
9394 Object . keys ( changedReports ?? { } ) . forEach ( ( key ) => {
94- const report = reports ?. [ key ] ;
95+ let report : Report | null = reports ?. [ key ] ?? null ;
9596 result [ key ] = report ;
97+ if ( reports ?. [ key ] === undefined && prevReports ?. [ key ] ) {
98+ report = null ;
99+ }
96100 } ) ;
97101 return result ;
98- } , [ changedReports , reports ] ) ;
102+ } , [ changedReports , reports , prevReports ] ) ;
99103
100104 /**
101105 * This effect is responsible for updating the options only for changed reports
0 commit comments