11import type { OnyxEntry } from 'react-native-onyx' ;
2- import { getOutstandingReportsForUser , isReportIneligibleForMoveExpenses , isSelfDM } from '@libs/ReportUtils' ;
2+ import { getOutstandingReportsForUser , isSelfDM } from '@libs/ReportUtils' ;
33import CONST from '@src/CONST' ;
44import ONYXKEYS from '@src/ONYXKEYS' ;
5- import type { Policy , Report } from '@src/types/onyx' ;
5+ import type { Policy } from '@src/types/onyx' ;
66import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
77import useMappedPolicies from './useMappedPolicies' ;
88import useOnyx from './useOnyx' ;
@@ -13,7 +13,6 @@ export default function useOutstandingReports(selectedReportID: string | undefin
1313 const [ outstandingReportsByPolicyID ] = useOnyx ( ONYXKEYS . DERIVED . OUTSTANDING_REPORTS_BY_POLICY_ID ) ;
1414 const [ personalPolicyID ] = useOnyx ( ONYXKEYS . PERSONAL_POLICY_ID ) ;
1515 const [ allPoliciesID ] = useMappedPolicies ( policyIdMapper ) ;
16- const [ allPolicies ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY ) ;
1716 const [ reportNameValuePairs ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS ) ;
1817 const [ selectedReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ selectedReportID } ` ) ;
1918
@@ -22,12 +21,6 @@ export default function useOutstandingReports(selectedReportID: string | undefin
2221 return [ ] ;
2322 }
2423
25- const filterEligibleReports = ( reports : Array < OnyxEntry < Report > > ) =>
26- reports . filter ( ( report ) => {
27- const policy = allPolicies ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ report ?. policyID } ` ] ;
28- return ! isReportIneligibleForMoveExpenses ( report , policy ) ;
29- } ) ;
30-
3124 if ( ! selectedPolicyID || selectedPolicyID === personalPolicyID || isSelfDM ( selectedReport ) ) {
3225 const result = [ ] ;
3326 for ( const policyID of Object . values ( allPoliciesID ?? { } ) ) {
@@ -38,10 +31,8 @@ export default function useOutstandingReports(selectedReportID: string | undefin
3831 const reports = getOutstandingReportsForUser ( policyID , ownerAccountID , outstandingReportsByPolicyID [ policyID ] ?? { } , reportNameValuePairs , isEditing ) ;
3932 result . push ( ...reports ) ;
4033 }
41- return filterEligibleReports ( result ) ;
34+ return result ;
4235 }
4336
44- return filterEligibleReports (
45- getOutstandingReportsForUser ( selectedPolicyID , ownerAccountID , outstandingReportsByPolicyID ?. [ selectedPolicyID ?? CONST . DEFAULT_NUMBER_ID ] ?? { } , reportNameValuePairs , isEditing ) ,
46- ) ;
37+ return getOutstandingReportsForUser ( selectedPolicyID , ownerAccountID , outstandingReportsByPolicyID ?. [ selectedPolicyID ?? CONST . DEFAULT_NUMBER_ID ] ?? { } , reportNameValuePairs , isEditing ) ;
4738}
0 commit comments