@@ -146,6 +146,7 @@ import {
146146 getSearchReportName ,
147147 hasHeldExpenses ,
148148 hasInvoiceReports ,
149+ hasOnlyNonReimbursableTransactions ,
149150 isAllowedToApproveExpenseReport as isAllowedToApproveExpenseReportUtils ,
150151 isArchivedReport ,
151152 isClosedReport ,
@@ -2409,9 +2410,9 @@ function getActions(
24092410 * @private
24102411 * Returns the primary action to show in the Action column for a given transaction or report
24112412 */
2412- function getAction ( allActions : SearchTransactionAction [ ] ) {
2413+ function getAction ( allActions : SearchTransactionAction [ ] , primaryActionExclusions : SearchTransactionAction [ ] = [ ] ) {
24132414 // Do not set CHANGE_APPROVER as the primary action as it is less frequently used than VIEW
2414- return allActions . find ( ( action ) => action !== CONST . SEARCH . ACTION_TYPES . CHANGE_APPROVER ) ?? CONST . SEARCH . ACTION_TYPES . VIEW ;
2415+ return allActions . find ( ( action ) => action !== CONST . SEARCH . ACTION_TYPES . CHANGE_APPROVER && ! primaryActionExclusions . includes ( action ) ) ?? CONST . SEARCH . ACTION_TYPES . VIEW ;
24152416}
24162417
24172418/**
@@ -2734,10 +2735,12 @@ function getReportSections({
27342735 reportItem . stateNum === CONST . REPORT . STATE_NUM . OPEN &&
27352736 reportItem . ownerAccountID === currentAccountID &&
27362737 reportItem . nextStep ?. messageKey === CONST . NEXT_STEP . MESSAGE_KEY . REJECTED_REPORT ;
2738+ const shouldHidePayAsPrimaryAction = hasOnlyNonReimbursableTransactions ( reportItem . reportID , allReportTransactions ) ;
2739+ const primaryActionExclusions : SearchTransactionAction [ ] = shouldHidePayAsPrimaryAction ? [ CONST . SEARCH . ACTION_TYPES . PAY ] : [ ] ;
27372740
27382741 reportIDToTransactions [ reportKey ] = {
27392742 ...reportItem ,
2740- action : getAction ( allActions ) ,
2743+ action : getAction ( allActions , primaryActionExclusions ) ,
27412744 allActions,
27422745 keyForList : String ( reportItem . reportID ) ,
27432746 groupedBy : CONST . SEARCH . DATA_TYPES . EXPENSE_REPORT ,
0 commit comments