11import { deepEqual } from 'fast-equals' ;
2- import React , { createContext , useCallback , useContext , useEffect , useMemo , useState } from 'react' ;
2+ import React , { createContext , useCallback , useContext , useEffect , useMemo , useRef , useState } from 'react' ;
33import type { OnyxEntry } from 'react-native-onyx' ;
44import Log from '@libs/Log' ;
55import { getPolicyEmployeeListByIdWithoutCurrentUser } from '@libs/PolicyUtils' ;
@@ -250,6 +250,7 @@ function SidebarOrderedReportsContextProvider({
250250 } ;
251251 const prevContextValue = usePrevious ( contextValue ) ;
252252 const previousDeps = usePrevious ( currentDeps ) ;
253+ const firstRender = useRef ( true ) ;
253254
254255 useEffect ( ( ) => {
255256 // Cases below ensure we only log when the edge case (empty -> non-empty or non-empty -> empty) happens.
@@ -263,6 +264,13 @@ function SidebarOrderedReportsContextProvider({
263264 if ( contextValue . orderedReports . length === 0 && prevContextValue ?. orderedReports . length > 0 ) {
264265 logChangedDeps ( '[useSidebarOrderedReports] Ordered reports went from non-empty to empty' , currentDeps , previousDeps ) ;
265266 }
267+
268+ // Case 3: orderedReports are empty from the beginning
269+ if ( firstRender . current && contextValue . orderedReports . length === 0 ) {
270+ logChangedDeps ( '[useSidebarOrderedReports] Ordered reports initialized empty' , currentDeps , previousDeps ) ;
271+ }
272+
273+ firstRender . current = false ;
266274 } ) ;
267275
268276 return < SidebarOrderedReportsContext . Provider value = { contextValue } > { children } </ SidebarOrderedReportsContext . Provider > ;
0 commit comments