From 73fc7b41db69f5f9ae3dbf7dbc355b66783b9ead Mon Sep 17 00:00:00 2001 From: Mohammad Luthfi Fathur Rahman Date: Tue, 3 Jun 2025 14:53:47 +0700 Subject: [PATCH] Revert "Fix the pending (unheld) approve amount when other expenses are held" --- src/libs/MoneyRequestReportUtils.ts | 7 +++---- tests/unit/MoneyRequestReportButtonUtils.test.ts | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/MoneyRequestReportUtils.ts b/src/libs/MoneyRequestReportUtils.ts index 75625660ccb1..dcbb7f1aa848 100644 --- a/src/libs/MoneyRequestReportUtils.ts +++ b/src/libs/MoneyRequestReportUtils.ts @@ -100,8 +100,7 @@ function shouldDisplayReportTableView(report: OnyxEntry, transactions: T * @returns - The total amount to be formatted as a string. Returns an empty string if no amount is applicable. */ const getTotalAmountForIOUReportPreviewButton = (report: OnyxEntry, policy: OnyxEntry, reportPreviewAction: ValueOf) => { - // Determine whether the non-held amount is appropriate to display for the PAY or APPROVE button. - const isPayOrApproveAction: boolean = reportPreviewAction === CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY || reportPreviewAction === CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE; + // Determine whether the non-held amount is appropriate to display for the PAY button. const {nonHeldAmount, hasValidNonHeldAmount} = getNonHeldAndFullAmount(report, reportPreviewAction === CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY); const hasOnlyHeldExpenses = hasOnlyHeldExpensesReportUtils(report?.reportID); const canAllowSettlement = hasUpdatedTotal(report, policy); @@ -109,8 +108,8 @@ const getTotalAmountForIOUReportPreviewButton = (report: OnyxEntry, poli // Split the total spend into different categories as needed. const {totalDisplaySpend, reimbursableSpend} = getMoneyRequestSpendBreakdown(report); - if (isPayOrApproveAction) { - // Return empty string if there are only held expenses which cannot be paid or approved. + if (reportPreviewAction === CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY) { + // Return empty string if there are only held expenses which cannot be paid. if (hasOnlyHeldExpenses) { return ''; } diff --git a/tests/unit/MoneyRequestReportButtonUtils.test.ts b/tests/unit/MoneyRequestReportButtonUtils.test.ts index b3d36b8df94c..ae95549ca3f1 100644 --- a/tests/unit/MoneyRequestReportButtonUtils.test.ts +++ b/tests/unit/MoneyRequestReportButtonUtils.test.ts @@ -45,7 +45,7 @@ describe('ReportButtonUtils', () => { it('returns total reimbursable spend for PAY & total value for other buttons', () => { expect(getTotalAmountForIOUReportPreviewButton(mockReport, mockPolicy, CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY)).toBe(`$50.00`); expect(getTotalAmountForIOUReportPreviewButton(mockReport, mockPolicy, CONST.REPORT.REPORT_PREVIEW_ACTIONS.REVIEW)).toBe(`$100.00`); - expect(getTotalAmountForIOUReportPreviewButton(mockReport, mockPolicy, CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE)).toBe(`$50.00`); + expect(getTotalAmountForIOUReportPreviewButton(mockReport, mockPolicy, CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE)).toBe(`$100.00`); expect(getTotalAmountForIOUReportPreviewButton(mockReport, mockPolicy, CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT)).toBe(`$100.00`); }); });