@@ -4235,9 +4235,12 @@ function canEditFieldOfMoneyRequest(reportAction: OnyxInputOrEntry<ReportAction>
42354235 // Unreported transaction from OldDot can have the reportID as an empty string
42364236 const isUnreported = ! transaction ?. reportID || transaction ?. reportID === CONST . REPORT . UNREPORTED_REPORT_ID ;
42374237 return isUnreported
4238- ? Object . values ( allPolicies ?? { } ) . flatMap ( ( currentPolicy ) => getOutstandingReportsForUser ( currentPolicy ?. id , currentUserAccountID , allReports ?? { } ) ) . length > 0
4239- : Object . values ( allPolicies ?? { } ) . flatMap ( ( currentPolicy ) => getOutstandingReportsForUser ( currentPolicy ?. id , moneyRequestReport ?. ownerAccountID , allReports ?? { } ) ) . length > 1 ||
4240- isOwner ;
4238+ ? Object . values ( allPolicies ?? { } ) . flatMap ( ( currentPolicy ) =>
4239+ getOutstandingReportsForUser ( currentPolicy ?. id , currentUserAccountID , reportsByPolicyID ?. [ currentPolicy ?. id ?? CONST . DEFAULT_NUMBER_ID ] ?? { } ) ,
4240+ ) . length > 0
4241+ : Object . values ( allPolicies ?? { } ) . flatMap ( ( currentPolicy ) =>
4242+ getOutstandingReportsForUser ( currentPolicy ?. id , moneyRequestReport ?. ownerAccountID , reportsByPolicyID ?. [ currentPolicy ?. id ?? CONST . DEFAULT_NUMBER_ID ] ?? { } ) ,
4243+ ) . length > 1 || isOwner ;
42414244 }
42424245
42434246 return true ;
@@ -10033,13 +10036,13 @@ function isReportOutstanding(
1003310036function getOutstandingReportsForUser (
1003410037 policyID : string | undefined ,
1003510038 reportOwnerAccountID : number | undefined ,
10036- reports : OnyxCollection < Report > = allReports ,
10039+ reports : Array < OnyxEntry < Report > > = Object . values ( allReports ?? { } ) ,
1003710040 reportNameValuePairs : OnyxCollection < ReportNameValuePairs > = allReportNameValuePair ,
1003810041) : Array < OnyxEntry < Report > > {
1003910042 if ( ! reports ) {
1004010043 return [ ] ;
1004110044 }
10042- return Object . values ( reports )
10045+ return reports
1004310046 . filter ( ( report ) => isReportOutstanding ( report , policyID , reportNameValuePairs ) && report ?. ownerAccountID === reportOwnerAccountID )
1004410047 . sort ( ( a , b ) => a ?. reportName ?. localeCompare ( b ?. reportName ?. toLowerCase ( ) ?? '' ) ?? 0 ) ;
1004510048}
0 commit comments