@@ -55,6 +55,7 @@ type GetReportPrimaryActionParams = {
5555 reportNameValuePairs ?: ReportNameValuePairs ;
5656 reportActions ?: ReportAction [ ] ;
5757 isChatReportArchived ?: boolean ;
58+ invoiceReceiverPolicy ?: Policy ;
5859} ;
5960
6061function isAddExpenseAction ( report : Report , reportTransactions : Transaction [ ] , isChatReportArchived = false ) {
@@ -140,7 +141,7 @@ function isApproveAction(report: Report, reportTransactions: Transaction[], poli
140141 return false ;
141142}
142143
143- function isPrimaryPayAction ( report : Report , policy ?: Policy , reportNameValuePairs ?: ReportNameValuePairs , isChatReportArchived ?: boolean ) {
144+ function isPrimaryPayAction ( report : Report , policy ?: Policy , reportNameValuePairs ?: ReportNameValuePairs , isChatReportArchived ?: boolean , invoiceReceiverPolicy ?: Policy ) {
144145 if ( isArchivedReport ( reportNameValuePairs ) || isChatReportArchived ) {
145146 return false ;
146147 }
@@ -182,7 +183,7 @@ function isPrimaryPayAction(report: Report, policy?: Policy, reportNameValuePair
182183 return parentReport ?. invoiceReceiver ?. accountID === getCurrentUserAccountID ( ) ;
183184 }
184185
185- return policy ?. role === CONST . POLICY . ROLE . ADMIN ;
186+ return invoiceReceiverPolicy ?. role === CONST . POLICY . ROLE . ADMIN ;
186187}
187188
188189function isExportAction ( report : Report , policy ?: Policy , reportActions ?: ReportAction [ ] ) {
@@ -302,7 +303,7 @@ function getAllExpensesToHoldIfApplicable(report?: Report, reportActions?: Repor
302303}
303304
304305function getReportPrimaryAction ( params : GetReportPrimaryActionParams ) : ValueOf < typeof CONST . REPORT . PRIMARY_ACTIONS > | '' {
305- const { report, reportTransactions, violations, policy, reportNameValuePairs, reportActions, isChatReportArchived, chatReport} = params ;
306+ const { report, reportTransactions, violations, policy, reportNameValuePairs, reportActions, isChatReportArchived, chatReport, invoiceReceiverPolicy } = params ;
306307
307308 const isPayActionWithAllExpensesHeld = isPrimaryPayAction ( report , policy , reportNameValuePairs , isChatReportArchived ) && hasOnlyHeldExpenses ( report ?. reportID ) ;
308309
@@ -330,7 +331,7 @@ function getReportPrimaryAction(params: GetReportPrimaryActionParams): ValueOf<t
330331 return CONST . REPORT . PRIMARY_ACTIONS . APPROVE ;
331332 }
332333
333- if ( isPrimaryPayAction ( report , policy , reportNameValuePairs , isChatReportArchived ) ) {
334+ if ( isPrimaryPayAction ( report , policy , reportNameValuePairs , isChatReportArchived , invoiceReceiverPolicy ) ) {
334335 return CONST . REPORT . PRIMARY_ACTIONS . PAY ;
335336 }
336337
0 commit comments