Skip to content

Commit d28df87

Browse files
committed
Fix non-reimbursable report row primary action
1 parent 1dd01da commit d28df87

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/libs/SearchUIUtils.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ import {
143143
getReportStatusTranslation,
144144
getSearchReportName,
145145
hasHeldExpenses,
146+
hasOnlyNonReimbursableTransactions,
146147
hasInvoiceReports,
147148
isAllowedToApproveExpenseReport as isAllowedToApproveExpenseReportUtils,
148149
isArchivedReport,
@@ -2378,9 +2379,12 @@ function getActions(
23782379
* @private
23792380
* Returns the primary action to show in the Action column for a given transaction or report
23802381
*/
2381-
function getAction(allActions: SearchTransactionAction[]) {
2382+
function getAction(allActions: SearchTransactionAction[], primaryActionExclusions: SearchTransactionAction[] = []) {
23822383
// Do not set CHANGE_APPROVER as the primary action as it is less frequently used than VIEW
2383-
return allActions.find((action) => action !== CONST.SEARCH.ACTION_TYPES.CHANGE_APPROVER) ?? CONST.SEARCH.ACTION_TYPES.VIEW;
2384+
return (
2385+
allActions.find((action) => action !== CONST.SEARCH.ACTION_TYPES.CHANGE_APPROVER && !primaryActionExclusions.includes(action)) ??
2386+
CONST.SEARCH.ACTION_TYPES.VIEW
2387+
);
23842388
}
23852389

23862390
/**
@@ -2708,10 +2712,12 @@ function getReportSections({
27082712
reportItem.stateNum === CONST.REPORT.STATE_NUM.OPEN &&
27092713
reportItem.ownerAccountID === currentAccountID &&
27102714
reportItem.nextStep?.messageKey === CONST.NEXT_STEP.MESSAGE_KEY.REJECTED_REPORT;
2715+
const shouldHidePayAsPrimaryAction = hasOnlyNonReimbursableTransactions(reportItem.reportID, allReportTransactions);
2716+
const primaryActionExclusions: SearchTransactionAction[] = shouldHidePayAsPrimaryAction ? [CONST.SEARCH.ACTION_TYPES.PAY] : [];
27112717

27122718
reportIDToTransactions[reportKey] = {
27132719
...reportItem,
2714-
action: getAction(allActions),
2720+
action: getAction(allActions, primaryActionExclusions),
27152721
allActions,
27162722
keyForList: String(reportItem.reportID),
27172723
groupedBy: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT,

0 commit comments

Comments
 (0)