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' ;
@@ -44,6 +45,8 @@ const policySelector = (policy: OnyxEntry<OnyxTypes.Policy>): PartialPolicyForSi
4445 employeeList : policy . employeeList ,
4546 } ) as PartialPolicyForSidebar ;
4647
48+ const policiesSelector = ( policies : OnyxCollection < OnyxTypes . Policy > ) => mapOnyxCollectionItems ( policies , policySelector ) ;
49+
4750function SidebarOrderedReportsContextProvider ( {
4851 children,
4952 /**
@@ -59,13 +62,13 @@ function SidebarOrderedReportsContextProvider({
5962 const { localeCompare} = useLocalize ( ) ;
6063 const [ priorityMode = CONST . PRIORITY_MODE . DEFAULT ] = useOnyx ( ONYXKEYS . NVP_PRIORITY_MODE , { canBeMissing : true } ) ;
6164 const [ chatReports , { sourceValue : reportUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT , { canBeMissing : true } ) ;
62- const [ policies , { sourceValue : policiesUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { selector : ( c ) => mapOnyxCollectionItems ( c , policySelector ) , canBeMissing : true } ) ;
65+ const [ policies , { sourceValue : policiesUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { selector : policiesSelector , canBeMissing : true } ) ;
6366 const [ transactions , { sourceValue : transactionsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION , { canBeMissing : true } ) ;
6467 const [ transactionViolations , { sourceValue : transactionViolationsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION_VIOLATIONS , { canBeMissing : true } ) ;
6568 const [ reportNameValuePairs , { sourceValue : reportNameValuePairsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS , { canBeMissing : true } ) ;
6669 const [ , { sourceValue : reportsDraftsUpdates } ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT_DRAFT_COMMENT , { canBeMissing : true } ) ;
6770 const [ betas ] = useOnyx ( ONYXKEYS . BETAS , { canBeMissing : true } ) ;
68- const [ reportAttributes ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES , { selector : ( value ) => value ?. reports , canBeMissing : true } ) ;
71+ const [ reportAttributes ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES , { selector : reportAttributesSelector , canBeMissing : true } ) ;
6972 const [ currentReportsToDisplay , setCurrentReportsToDisplay ] = useState < ReportsToDisplayInLHN > ( { } ) ;
7073
7174 const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
0 commit comments