11import { deepEqual } from 'fast-equals' ;
22import React , { createContext , useCallback , useContext , useEffect , useMemo , useRef , useState } from 'react' ;
3- import type { OnyxEntry } from 'react-native-onyx' ;
3+ import type { OnyxCollection , OnyxEntry } from 'react-native-onyx' ;
44import Log from '@libs/Log' ;
55import { getPolicyEmployeeListByIdWithoutCurrentUser } from '@libs/PolicyUtils' ;
6+ import { reportAttributesSelector } from '@libs/ReportUtils' ;
67import SidebarUtils from '@libs/SidebarUtils' ;
78import CONST from '@src/CONST' ;
89import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -43,6 +44,8 @@ const policySelector = (policy: OnyxEntry<OnyxTypes.Policy>): PartialPolicyForSi
4344 employeeList : policy . employeeList ,
4445 } ) as PartialPolicyForSidebar ;
4546
47+ const policiesSelector = ( policies : OnyxCollection < OnyxTypes . Policy > ) => mapOnyxCollectionItems ( policies , policySelector ) ;
48+
4649function SidebarOrderedReportsContextProvider ( {
4750 children,
4851 /**
@@ -57,13 +60,13 @@ function SidebarOrderedReportsContextProvider({
5760} : SidebarOrderedReportsContextProviderProps ) {
5861 const [ priorityMode = CONST . PRIORITY_MODE . DEFAULT ] = useOnyx ( ONYXKEYS . NVP_PRIORITY_MODE , { canBeMissing : true } ) ;
5962 const [ chatReports , { sourceValue : reportUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT , { canBeMissing : true } ) ;
60- const [ policies , { sourceValue : policiesUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { selector : ( c ) => mapOnyxCollectionItems ( c , policySelector ) , canBeMissing : true } ) ;
63+ const [ policies , { sourceValue : policiesUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { selector : policiesSelector , canBeMissing : true } ) ;
6164 const [ transactions , { sourceValue : transactionsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION , { canBeMissing : true } ) ;
6265 const [ transactionViolations , { sourceValue : transactionViolationsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION_VIOLATIONS , { canBeMissing : true } ) ;
6366 const [ reportNameValuePairs , { sourceValue : reportNameValuePairsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS , { canBeMissing : true } ) ;
6467 const [ , { sourceValue : reportsDraftsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT_DRAFT_COMMENT , { canBeMissing : true } ) ;
6568 const [ betas ] = useOnyx ( ONYXKEYS . BETAS , { canBeMissing : true } ) ;
66- const [ reportAttributes ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES , { selector : ( value ) => value ?. reports , canBeMissing : true } ) ;
69+ const [ reportAttributes ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES , { selector : reportAttributesSelector , canBeMissing : true } ) ;
6770 const [ currentReportsToDisplay , setCurrentReportsToDisplay ] = useState < ReportsToDisplayInLHN > ( { } ) ;
6871
6972 const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
0 commit comments