11import { deepEqual } from 'fast-equals' ;
22import React , { createContext , useCallback , useContext , useEffect , useMemo , useRef , useState } from 'react' ;
3- import type { OnyxCollection , OnyxEntry } from 'react-native-onyx' ;
3+ import type { OnyxEntry } from 'react-native-onyx' ;
44import Log from '@libs/Log' ;
55import { getPolicyEmployeeListByIdWithoutCurrentUser } from '@libs/PolicyUtils' ;
6- import { reportAttributesSelector } from '@libs/ReportUtils' ;
76import SidebarUtils from '@libs/SidebarUtils' ;
87import CONST from '@src/CONST' ;
98import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -45,8 +44,6 @@ const policySelector = (policy: OnyxEntry<OnyxTypes.Policy>): PartialPolicyForSi
4544 employeeList : policy . employeeList ,
4645 } ) as PartialPolicyForSidebar ;
4746
48- const policiesSelector = ( policies : OnyxCollection < OnyxTypes . Policy > ) => mapOnyxCollectionItems ( policies , policySelector ) ;
49-
5047function SidebarOrderedReportsContextProvider ( {
5148 children,
5249 /**
@@ -62,13 +59,13 @@ function SidebarOrderedReportsContextProvider({
6259 const { localeCompare} = useLocalize ( ) ;
6360 const [ priorityMode = CONST . PRIORITY_MODE . DEFAULT ] = useOnyx ( ONYXKEYS . NVP_PRIORITY_MODE , { canBeMissing : true } ) ;
6461 const [ chatReports , { sourceValue : reportUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT , { canBeMissing : true } ) ;
65- const [ policies , { sourceValue : policiesUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { selector : policiesSelector , canBeMissing : true } ) ;
62+ const [ policies , { sourceValue : policiesUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { selector : ( c ) => mapOnyxCollectionItems ( c , policySelector ) , canBeMissing : true } ) ;
6663 const [ transactions , { sourceValue : transactionsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION , { canBeMissing : true } ) ;
6764 const [ transactionViolations , { sourceValue : transactionViolationsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION_VIOLATIONS , { canBeMissing : true } ) ;
6865 const [ reportNameValuePairs , { sourceValue : reportNameValuePairsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS , { canBeMissing : true } ) ;
6966 const [ , { sourceValue : reportsDraftsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT_DRAFT_COMMENT , { canBeMissing : true } ) ;
7067 const [ betas ] = useOnyx ( ONYXKEYS . BETAS , { canBeMissing : true } ) ;
71- const [ reportAttributes ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES , { selector : reportAttributesSelector , canBeMissing : true } ) ;
68+ const [ reportAttributes ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES , { selector : ( value ) => value ?. reports , canBeMissing : true } ) ;
7269 const [ currentReportsToDisplay , setCurrentReportsToDisplay ] = useState < ReportsToDisplayInLHN > ( { } ) ;
7370
7471 const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
0 commit comments