diff --git a/src/libs/MoneyRequestReportUtils.ts b/src/libs/MoneyRequestReportUtils.ts index dcbb7f1aa84..75625660ccb 100644 --- a/src/libs/MoneyRequestReportUtils.ts +++ b/src/libs/MoneyRequestReportUtils.ts @@ -100,7 +100,8 @@ 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 button. + // 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; const {nonHeldAmount, hasValidNonHeldAmount} = getNonHeldAndFullAmount(report, reportPreviewAction === CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY); const hasOnlyHeldExpenses = hasOnlyHeldExpensesReportUtils(report?.reportID); const canAllowSettlement = hasUpdatedTotal(report, policy); @@ -108,8 +109,8 @@ const getTotalAmountForIOUReportPreviewButton = (report: OnyxEntry, poli // Split the total spend into different categories as needed. const {totalDisplaySpend, reimbursableSpend} = getMoneyRequestSpendBreakdown(report); - if (reportPreviewAction === CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY) { - // Return empty string if there are only held expenses which cannot be paid. + if (isPayOrApproveAction) { + // Return empty string if there are only held expenses which cannot be paid or approved. if (hasOnlyHeldExpenses) { return ''; } diff --git a/tests/unit/MoneyRequestReportButtonUtils.test.ts b/tests/unit/MoneyRequestReportButtonUtils.test.ts index ae95549ca3f..b3d36b8df94 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(`$100.00`); + expect(getTotalAmountForIOUReportPreviewButton(mockReport, mockPolicy, CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE)).toBe(`$50.00`); expect(getTotalAmountForIOUReportPreviewButton(mockReport, mockPolicy, CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT)).toBe(`$100.00`); }); });