Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/libs/MoneyRequestReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,16 @@ function shouldDisplayReportTableView(report: OnyxEntry<Report>, 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<Report>, policy: OnyxEntry<Policy>, reportPreviewAction: ValueOf<typeof CONST.REPORT.REPORT_PREVIEW_ACTIONS>) => {
// 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);

// 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 '';
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/MoneyRequestReportButtonUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
});
});
Expand Down