@@ -2,7 +2,7 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
22import type { ValueOf } from 'type-fest' ;
33import CONST from '@src/CONST' ;
44import ONYXKEYS from '@src/ONYXKEYS' ;
5- import type { Policy , Report , ReportAction , ReportMetadata , ReportNameValuePairs , Transaction , TransactionViolation } from '@src/types/onyx' ;
5+ import type { BankAccountList , Policy , Report , ReportAction , ReportMetadata , ReportNameValuePairs , Transaction , TransactionViolation } from '@src/types/onyx' ;
66import { isApprover as isApproverUtils } from './actions/Policy/Member' ;
77import { getCurrentUserAccountID } from './actions/Report' ;
88import {
@@ -58,6 +58,7 @@ type GetReportPrimaryActionParams = {
5858 chatReport : OnyxEntry < Report > ;
5959 reportTransactions : Transaction [ ] ;
6060 violations : OnyxCollection < TransactionViolation [ ] > ;
61+ bankAccountList : OnyxEntry < BankAccountList > ;
6162 policy ?: Policy ;
6263 reportNameValuePairs ?: ReportNameValuePairs ;
6364 reportActions ?: ReportAction [ ] ;
@@ -159,6 +160,7 @@ function isPrimaryPayAction(
159160 report : Report ,
160161 currentUserAccountID : number ,
161162 currentUserEmail : string ,
163+ bankAccountList : OnyxEntry < BankAccountList > ,
162164 policy ?: Policy ,
163165 reportNameValuePairs ?: ReportNameValuePairs ,
164166 isChatReportArchived ?: boolean ,
@@ -170,7 +172,7 @@ function isPrimaryPayAction(
170172 return false ;
171173 }
172174 const isExpenseReport = isExpenseReportUtils ( report ) ;
173- const isReportPayer = isPayer ( currentUserAccountID , currentUserEmail , report , false , policy ) ;
175+ const isReportPayer = isPayer ( currentUserAccountID , currentUserEmail , report , bankAccountList , policy , false ) ;
174176 const arePaymentsEnabled = arePaymentsEnabledUtils ( policy ) ;
175177 const isReportApproved = isReportApprovedUtils ( { report} ) ;
176178 const isReportClosed = isClosedReportUtils ( report ) ;
@@ -404,6 +406,7 @@ function getReportPrimaryAction(params: GetReportPrimaryActionParams): ValueOf<t
404406 report,
405407 reportTransactions,
406408 violations,
409+ bankAccountList,
407410 policy,
408411 reportNameValuePairs,
409412 reportActions,
@@ -434,7 +437,7 @@ function getReportPrimaryAction(params: GetReportPrimaryActionParams): ValueOf<t
434437 }
435438
436439 const isPayActionWithAllExpensesHeld =
437- isPrimaryPayAction ( report , currentUserAccountID , currentUserEmail , policy , reportNameValuePairs , isChatReportArchived , invoiceReceiverPolicy , reportActions ) &&
440+ isPrimaryPayAction ( report , currentUserAccountID , currentUserEmail , bankAccountList , policy , reportNameValuePairs , isChatReportArchived , invoiceReceiverPolicy , reportActions ) &&
438441 hasOnlyHeldExpenses ( report ?. reportID ) ;
439442 const expensesToHold = getAllExpensesToHoldIfApplicable ( report , reportActions , reportTransactions , policy ) ;
440443
@@ -462,7 +465,7 @@ function getReportPrimaryAction(params: GetReportPrimaryActionParams): ValueOf<t
462465 return CONST . REPORT . PRIMARY_ACTIONS . SUBMIT ;
463466 }
464467
465- if ( isPrimaryPayAction ( report , currentUserAccountID , currentUserEmail , policy , reportNameValuePairs , isChatReportArchived , invoiceReceiverPolicy , reportActions ) ) {
468+ if ( isPrimaryPayAction ( report , currentUserAccountID , currentUserEmail , bankAccountList , policy , reportNameValuePairs , isChatReportArchived , invoiceReceiverPolicy , reportActions ) ) {
466469 return CONST . REPORT . PRIMARY_ACTIONS . PAY ;
467470 }
468471
0 commit comments