[$175] Report- Pay button is displayed to $0.0 report
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: v9.5.39-2 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/83789013/folder/57605193/62969908/1974347278 Email or phone of affected tester (no customers): N/A Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Windows 10/Chrome App Component: Chat Report View
Action Performed:
Preconditions:
- Create a new account, create a workspace
- Open https://staging.new.expensify.com/
- Navigate to workspace chat
- Create a $50 expense
- Create a -$50 expense
- Click Submit button
- Click Approve button
- Open the Expense report
Expected Result:
Pay button is hidden for a 0.00 report
Actual Result:
Pay button is displayed for a 0.00 report
Workaround:
Unknown
Platforms:
- [x] Android: App
- [x] Android: mWeb Chrome
- [x] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [ ] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/03d334b0-71d2-4e6a-9a27-4e909786ad2e
Applause Internal Information Exported by: Rizky Gunawan Bug ID: 7313627
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022122143384181168798
- Upwork Job ID: 2122143384181168798
- Last Price Increase: 2026-11-16
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/7777eb5ce8b7f6de4be302143502cbb705a7a0612c87c9ab4182d29c7be1ea5d
Triggered auto assignment to Contributor-plus team member for initial proposal review - @daledah (External)
Job added to Upwork: https://www.upwork.com/jobs/~022122143384181168798
Proposal
What is the root cause of that problem?
The report deliberately allows Mark as paid for settled expenses that cancel out to $0. The header exposes that capability using the generic Pay button.
This is a mismatch with the issue’s expected presentation—not a missing check allowing an actual $0 payment.
Code evidence and validation
- ReportPrimaryActionUtils.ts:253–267 explicitly makes settled zero-balance reports eligible for the primary Pay action.
- ReportUtils.ts:3545–3572 blocks actual payment at zero while permitting Mark as paid.
- SettlementButton/index.tsx:283–286 restricts the menu to Mark as paid, but lines 557–594 independently retain the generic Pay label.
- The exact approved +$50/−$50 scenario is covered by ReportWorkflowTest.ts:4460–4510: actual payment is denied; Mark as paid is allowed.
Six targeted existing tests passed, including cancellation, empty-report, non-reimbursable, and failed-scan cases. No browser reproduction was performed. Confidence: medium for the reported UI diagnosis; the underlying behavior is explicitly supported by code and tests.
What changes do you think we should make in order to solve the problem?
To meet the stated expectation, hide the primary Pay action for settled zero-total reports, while retaining Mark as paid in the secondary menu so users can still complete them. Keep report-preview behavior consistent.
Do not simply reject every zero-total report in payment eligibility: that would remove the existing completion capability and could misclassify reports whose receipts are still scanning.
Implementation scope and regression coverage
The primary and preview selectors need coordinated changes. Preserve shared settlement eligibility, and add the secondary completion action explicitly: ReportSecondaryActionUtils.ts:1082–1099 currently offers secondary Pay only for held-expense or export-failure cases.
Update the existing zero-balance primary-action expectations. Verify that positive reports retain Pay, settled cancellation reports retain secondary completion, and empty/scanning reports do not become eligible prematurely. Preserve negative-credit behavior and non-reimbursable policy restrictions.
What alternative solutions did you explore? (Optional)
Rename the zero-report button Mark as paid instead. This preserves current behavior with a smaller change, but does not satisfy the stated expectation that Pay be hidden.
Related issue: Ready to pay shows non-reimbursable-only reports until their transactions load concerns the same payment-optional classification, but a different surface and loading condition; it is not a confirmed duplicate.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/106952) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
Proposal
Please re-state the problem that we are trying to solve in this issue.
An approved expense report whose total is $0.00 (for example a $50 expense and a -$50 expense) still shows a green Pay $0.00 button in the report header and in the report preview. Nothing is owed on that report, so a Pay button should not be offered there.
What is the root cause of that problem?
This is not a missing check. The behavior was added on purpose in #102347 (for #102215), so that an approved report with nothing left to reimburse can still be closed out with Mark as paid, the same way Classic does it. That PR added hasSettledZeroReimbursableSpend and put it into the three Pay checks:
https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/libs/ReportUtils.ts#L5610-L5620
- report header / More menu,
isPrimaryPayAction: https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/libs/ReportPrimaryActionUtils.ts#L257-L267 - report preview,
canPay: https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/libs/ReportPreviewActionUtils.ts#L182-L192 canIOUBePaid, only on the pay-elsewhere path, so the button can only mark as paid and never send money: https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/libs/ReportUtils.ts#L3546-L3550
The same PR also decided these reports should not be pushed at the payer as something to pay. It added isPayOptional and used it to drop Pay from the LHN badge, the Reports row action (falls back to View) and the Ready to pay to-do:
https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/libs/ReportUtils.ts#L5622-L5628 https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/libs/SearchUIUtils.ts#L3131-L3135 https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/libs/TodosUtils.ts#L168
But the report header and the report preview never got that exclusion. getReportPrimaryAction returns PAY whenever isPrimaryPayAction is true and the expenses aren't all held:
https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/libs/ReportPrimaryActionUtils.ts#L582-L599
and getReportPreviewAction returns PAY whenever canPay is true:
https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/libs/ReportPreviewActionUtils.ts#L335-L337
Both then render SettlementButton, whose label is always Pay <amount> (iou.settlePayment), even when the only option in the dropdown is Mark as paid:
https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/components/SettlementButton/index.tsx#L557-L562
So on the same $0 report the Reports list shows View and the LHN shows no badge, while the header and the preview show a primary "Pay $0.00". That inconsistency is the bug QA is seeing.
What changes do you think we should make in order to solve the problem?
Keep the Mark as paid capability from #102347, but stop presenting it as the primary Pay action when the report total is $0.
- Add a small helper in
ReportUtils.ts, next tohasSettledZeroReimbursableSpend. When the total is 0,getMoneyRequestSpendBreakdownreturns all three values as 0 (https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/libs/ReportUtils.ts#L5598-L5602), so this covers +$50/-$50, a single $0 expense, and mixed reimbursable/non-reimbursable that nets to 0:
/** The report total is $0 and every expense has a final value, so nothing is owed and it can only be marked as paid. */
function hasSettledZeroTotal(report: OnyxInputOrEntry<Report>, transactions?: Transaction[]): boolean {
const spendBreakdown = getMoneyRequestSpendBreakdown(report);
return spendBreakdown.totalDisplaySpend === 0 && hasSettledZeroReimbursableSpend(spendBreakdown, report, transactions);
}
I would not reuse isPayOptional here. It is also true for non-reimbursable-only reports with a non-zero total, where the header shows "Pay $X" with Mark as paid today. That is a separate behavior and out of scope for this issue.
- Report header: skip
PAYingetReportPrimaryActionfor these reports, so it falls through to Export / Remove hold / nothing, the same as the Reports row:
if (
isPrimaryPayAction({...}) &&
!allExpensesHeld &&
!hasSettledZeroTotal(report, reportTransactions)
) {
return CONST.REPORT.PRIMARY_ACTIONS.PAY;
}
I'd put the check here and not inside isPrimaryPayAction, because isPrimaryPayAction is also used by the More menu and by TodosUtils, and the More menu still needs it to be true (step 3).
- More menu: keep the close-out.
getSecondaryReportActionsonly addsSECONDARY_ACTIONS.PAYfor held expenses or a failed export (https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/libs/ReportSecondaryActionUtils.ts#L1082-L1099). Add the zero-total case:
(hasOnlyHeldExpenses(reportTransactions) || didExportFail || hasSettledZeroTotal(report, reportTransactions))
In MoneyReportHeaderSecondaryActions.tsx the PAY entry is labelled Pay $0.00 with a submenu (https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/src/components/MoneyReportHeaderActions/MoneyReportHeaderSecondaryActions.tsx#L458-L466). For a zero-total report I'd render it as a single "Mark as paid" item (translate('iou.payElsewhere') with no amount) that calls the existing confirmPayment({paymentType: CONST.IOU.PAYMENT_TYPE.ELSEWHERE}). That way the word "Pay" doesn't come back through the menu, and the hold and delegate checks inside confirmPayment still apply.
- Report preview: same exclusion in
getReportPreviewAction, so the preview shows View:
if (
canPay(report, isReportArchived, currentUserAccountID, currentUserLogin, bankAccountList, transactions, policy, invoiceReceiverPolicy) &&
!hasSettledZeroTotal(report, transactions)
) {
return CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY;
}
canIOUBePaid stays as it is, so the More menu item can still mark the report as paid. The LHN badge, Reports row and to-do already exclude these reports, so they don't change.
Note for the C+/internal reviewer: #102347 deliberately added "Pay $0.00 > Mark as paid" to the header and preview, so it's worth confirming the regression test expectation before we change it. If the team would rather keep a visible primary button, the alternative below is the smaller change.
What specific scenarios should we cover in automated tests to prevent reoccurrence?
tests/unit/ReportPrimaryActionUtilsTest.ts
- Update
should return PAY for expense report whose reimbursable expenses cancel out to 0(https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/tests/unit/ReportPrimaryActionUtilsTest.ts#L1454-L1488) so that the +$50/-$50 approved report does not returnPAY. - A single $0.00 expense, and a +$50 reimbursable / -$50 non-reimbursable report, also do not return
PAY. - Reimbursable expenses that cancel out plus a $100 non-reimbursable expense (total $100) still return
PAY. - A positive report still returns
PAY.
tests/unit/ReportSecondaryActionUtilsTest.ts
- The approved +$50/-$50 report includes
SECONDARY_ACTIONS.PAY. - A $0 report with a scanning or failed-scan expense, or with no expenses, does not include it.
tests/actions/ReportPreviewActionUtilsTest.ts
- Update
canPay should return PAY for an expense report with a zero total that is ready to be paid(https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/tests/actions/ReportPreviewActionUtilsTest.ts#L1343) to expectVIEWfromgetReportPreviewAction.
tests/actions/IOUTest/ReportWorkflowTest.ts
- Keep
should only allow marking as paid for report whose reimbursable expenses cancel out to 0(https://github.com/Expensify/App/blob/e0941699c3021c47f7b8fae79900294bc1780d05/tests/actions/IOUTest/ReportWorkflowTest.ts#L4460) passing unchanged, so we know the close-out still works.
What alternative solutions did you explore? (Optional)
- Keep the primary button but label it "Mark as paid" when the total is $0. Pass a flag into
SettlementButtonand useiou.payElsewhereascustomText. This is the smallest diff and keeps the one-click close-out, but it doesn't match the expected result that the Pay button is hidden, and the header would still push an action that the LHN and Reports list treat as optional. - Return false from
isPrimaryPayAction/canPayfor $0 totals. I rejected this because it would also remove the More menu entry and leave approved $0 reports with no way to close them, which is what #102215 fixed. - Use
isPayOptionaleverywhere. I rejected this because it would also hide Pay on non-reimbursable-only reports with a real total, which is outside this issue.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On an approved expense report whose total is $0.00 (for example, where expenses cancel out: a $50 expense and a -$50 expense), the report header and chat report preview display a primary green "Pay $0.00" button. Because nothing is owed on the report, a primary Pay button should not be displayed.
What is the root cause of that problem?
In PR #102347 (addressing #102215), hasSettledZeroReimbursableSpend was introduced so that users could close out approved $0.00 reports using Mark as paid (which was previously impossible).
However, hasSettledZeroReimbursableSpend was included in the primary payment eligibility checks:
ReportPrimaryActionUtils.ts:257-267:isPrimaryPayActionevaluates totruebecause(nonReimbursableSpend !== 0 || hasSettledZeroReimbursableSpend(...))passes even whenreimbursableSpend === 0andnonReimbursableSpend === 0. BecauseisSecondaryActionis not passed bygetReportPrimaryAction, it returns!didExportFail(true), causinggetReportPrimaryActionto returnCONST.REPORT.PRIMARY_ACTIONS.PAY.ReportPreviewActionUtils.ts:182-192:canPaysimilarly evaluates totrueforhasSettledZeroReimbursableSpend, causinggetReportPreviewActionto returnCONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY.
Consequently:
- While
SearchUIUtils.ts:2493(isPayOptional) andTodosUtils.ts:168intentionally hide the Pay action for zero-spend reports, the report header and preview card still expose a primary button labeled "Pay $0.00" (viaSettlementButton), opening a dropdown where the only option is "Mark as paid". - This contradicts the regression test requirement where the primary Pay button must be hidden for a $0.00 report.
What changes do you think we should make in order to solve the problem?
We should hide the primary Pay action on the report header and report preview when the settled report balance is $0.00, while preserving the ability to close out the report via "Mark as paid" in the secondary actions ("..." More menu):
-
src/libs/ReportPrimaryActionUtils.ts: InisPrimaryPayAction, qualifyhasSettledZeroReimbursableSpendso that a settled zero-spend report (hasSettledZeroReimbursableSpend(spendBreakdown, report, reportTransactions) && nonReimbursableSpend === 0) is only eligible when called for secondary actions (isSecondaryAction === true):const isSettledZeroReport = hasSettledZeroReimbursableSpend(spendBreakdown, report, reportTransactions) && nonReimbursableSpend === 0; if ( canPayReport && isExpenseReport && arePaymentsEnabled && isReportFinished && (reimbursableSpend !== 0 || ((nonReimbursableSpend !== 0 || (isSettledZeroReport && isSecondaryAction)) && !(policy?.preventPayoutNonReimbursableReports && hasOnlyNonReimbursableTransactions(report?.reportID, reportTransactions)))) ) { return isSecondaryAction ?? !didExportFail; }This ensures
getReportPrimaryActionwill not returnCONST.REPORT.PRIMARY_ACTIONS.PAYwhen the total is $0.00 (falling through cleanly toEXPORT_TO_ACCOUNTINGif an integration is connected, or empty string). -
src/libs/ReportPreviewActionUtils.ts: IncanPay, exclude reports wherehasSettledZeroReimbursableSpendis true andnonReimbursableSpend === 0:const isSettledZeroReport = hasSettledZeroReimbursableSpend(spendBreakdown, report, transactions) && nonReimbursableSpend === 0; if ( isExpense && canPayReport && isPaymentsEnabled && isReportFinished && !isSettledZeroReport && (reimbursableSpend !== 0 || (nonReimbursableSpend !== 0 && !(policy?.preventPayoutNonReimbursableReports && hasOnlyNonReimbursableTransactions(report?.reportID, transactions)))) ) { return !didExportFail; }This ensures
getReportPreviewActionfalls through toEXPORT_TO_ACCOUNTINGorVIEW. -
src/libs/ReportSecondaryActionUtils.ts: IngetSecondaryReportActions, permitCONST.REPORT.SECONDARY_ACTIONS.PAYwhen the report is a settled zero-spend report so the approver can close it out:const spendBreakdown = getMoneyRequestSpendBreakdown(report); const isSettledZeroReport = hasSettledZeroReimbursableSpend(spendBreakdown, report, reportTransactions) && spendBreakdown.nonReimbursableSpend === 0; if ( isPrimaryPayAction({ report, reportTransactions, currentUserAccountID, currentUserLogin, bankAccountList, policy, reportNameValuePairs, isChatReportArchived, reportActions, isSecondaryAction: true, canNonPayerAdminPay: true, }) && (hasOnlyHeldExpenses(reportTransactions) || didExportFail || isSettledZeroReport) ) { options.push(CONST.REPORT.SECONDARY_ACTIONS.PAY); } -
src/components/MoneyReportHeaderActions/MoneyReportHeaderSecondaryActions.tsx: When renderingCONST.REPORT.SECONDARY_ACTIONS.PAYfor a settled zero report (whereonlyShowPayElsewhereis true and total is $0), rather than displaying a nested submenu labeled"Pay $0.00"with a single child item, render it directly as a single menu action:- Label:
translate('iou.payElsewhere')("Mark as paid") - Icon:
expensifyIcons.Cash(orexpensifyIcons.Checkmark) onSelected: callsconfirmPayment({paymentType: CONST.IOU.PAYMENT_TYPE.ELSEWHERE})directly, maintaining all delegate and hold verifications.
- Label:
What alternative solutions did you explore? (Optional)
- Change the primary button label to "Mark as paid" instead of hiding it:
In
SettlementButton, ifonlyShowPayElsewhereis true and amount is 0, displaytranslate('iou.payElsewhere')("Mark as paid") ascustomText. While this provides a one-click primary close-out button, it does not satisfy the regression test's explicit expected result that the Pay button is hidden for a $0.00 report. - Add a separate helper
hasSettledZeroTotalinReportUtils.ts: Unnecessary, becausespendBreakdownis already computed in each caller, andhasSettledZeroReimbursableSpend(...) && nonReimbursableSpend === 0precisely defines a settled $0 report without adding new global helper functions.
What specific scenarios should we cover in automated tests to prevent reoccurrence?
tests/unit/ReportPrimaryActionUtilsTest.ts:- Update
should return PAY for expense report whose reimbursable expenses cancel out to 0to verify thatgetReportPrimaryActionreturns''(orEXPORT_TO_ACCOUNTINGif an integration exists), confirmingPAYis hidden. - Verify that positive reports (e.g. +$50 reimbursable) continue to return
CONST.REPORT.PRIMARY_ACTIONS.PAY. - Verify that reports with reimbursable cancelling to $0 plus non-reimbursable spend (e.g. +$50 / -$50 reimbursable, +$100 non-reimbursable) still return
CONST.REPORT.PRIMARY_ACTIONS.PAY.
- Update
tests/unit/ReportSecondaryActionUtilsTest.ts:- Test that an approved expense report whose expenses cancel out to $0 includes
CONST.REPORT.SECONDARY_ACTIONS.PAYingetSecondaryReportActions. - Test that a $0 report with scanning, pending, or failed-scan transactions does NOT include
CONST.REPORT.SECONDARY_ACTIONS.PAY.
- Test that an approved expense report whose expenses cancel out to $0 includes
tests/actions/ReportPreviewActionUtilsTest.ts:- Update
canPay should return PAY for an expense report with a zero total that is ready to be paidto verify thatgetReportPreviewActionreturnsCONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW.
- Update
tests/actions/IOUTest/ReportWorkflowTest.ts:- Verify that
canIOUBePaid(fakeReport, ..., cancellingTransactions, true, false)remainstrue, confirming the report can successfully be marked as paid.
- Verify that
Contributor details
- Email: [email protected]
- Upwork Profile: https://www.upwork.com/freelancers/~0131dae36abcf59374
Proposal
Please re-state the problem that we are trying to solve in this issue.
An expense report whose expenses net to $0.00 (such as $50 and -$50) shows a primary Pay $0.00 button after submission and approval. The expected behavior hides Pay on $0.00 reports.
What is the root cause of that problem?
Settled $0.00 expense reports are explicitly marked eligible for primary Pay in both the report header and chat preview selectors:
hasSettledZeroReimbursableSpend(src/libs/ReportUtils.ts:5610-5620) returnstruewhenreimbursableSpend === 0, the total is loaded and non-pending, and settled expenses exist.- Both
isPrimaryPayAction(src/libs/ReportPrimaryActionUtils.ts:257-267) andcanPay(src/libs/ReportPreviewActionUtils.ts:182-192) callhasSettledZeroReimbursableSpend(...). ThereforegetReportPrimaryAction(L582-L599) andgetReportPreviewAction(L335-L337) returnPAY. - In
PayPrimaryAction.tsx:87-113anduseReportPreviewActionDecision.ts:58-84,canIOUBePaid(..., false)returnsfalse. However,canIOUBePaid(..., true)returnstrueviacanShowMarkedAsPaidForZeroReimbursableSpend(src/libs/ReportUtils.ts:3547-3550). This setsonlyShowPayElsewhere = true. SettlementButton(src/components/SettlementButton/index.tsx:285-287) limits the dropdown toMark as paid(ELSEWHERE). Meanwhile, lines557-562renderPay $0.00usinggetTotalAmountForIOUReportPreviewButton(src/libs/MoneyRequestReportUtils.ts:244).
Note for maintainers: PR #102347 added hasSettledZeroReimbursableSpend for #102215 so approved $0 reports can close via Mark as paid.
What changes do you think we should make in order to solve the problem?
Hide the primary Pay button on $0.00 reports while preserving direct Mark as paid close-out in the More and selection-mode menus:
- Add a zero-total helper:
- Add
hasSettledZeroTotal(report, transactions)insrc/libs/ReportUtils.ts:5610-5620. RequirespendBreakdown.totalDisplaySpend === 0(L5598-L5602) alongsidehasSettledZeroReimbursableSpend(...). That avoids matching reports with non-zero non-reimbursable spend.
- Add
- Hide primary and preview
Payfor$0.00reports:- In
isPrimaryPayAction(src/libs/ReportPrimaryActionUtils.ts:257-267), gatehasSettledZeroReimbursableSpend(...)on!!isSecondaryActionwhennonReimbursableSpend === 0. - In
canPay(src/libs/ReportPreviewActionUtils.ts:182-192), remove thehasSettledZeroReimbursableSpend(...)fallback so the chat preview falls back fromPAY.
- In
- Expose direct
Mark as paidinMorewithout a submenu:- Keep
canShowMarkedAsPaidForZeroReimbursableSpendincanIOUBePaid(src/libs/ReportUtils.ts:3547-3550) unchanged soonlyShowPayElsewhereremainstrue. - In
getSecondaryReportActions(src/libs/ReportSecondaryActionUtils.ts:1082-1099), includeSECONDARY_ACTIONS.PAYwhenisPrimaryPayAction(..., isSecondaryAction: true)passes andhasSettledZeroTotal(report, reportTransactions)istrue. RequiringtotalDisplaySpend === 0prevents addingSECONDARY_ACTIONS.PAYto non-zero non-reimbursable reports. - In
MoneyReportHeaderSecondaryActions.tsx:290-304, passnonPendingDeleteTransactionsinstead ofundefined(lines297and304) tocanIOUBePaidActionsoonlyShowPayElsewherestays accurate. - In
MoneyReportHeaderSecondaryActions.tsx:458-466, checkonlyShowPayElsewhere && hasSettledZeroTotal(moneyRequestReport, nonPendingDeleteTransactions). Rendertranslate('iou.payElsewhere', '')(Mark as paid), omitrightIcon,backButtonText, andsubMenuItems, and setonSelectedto callonPaymentSelect(undefined, CONST.IOU.PAYMENT_TYPE.ELSEWHERE, () => {})(L476-L511). Routing throughonPaymentSelectinstead of callingconfirmPaymentdirectly preservesselectPaymentTypeand itsshouldRestrictUserBillableActionsguard (PaymentUtils.ts:251-254) while avoiding a redundant submenu showingMark $0.00 as paid(src/hooks/usePaymentOptions.ts:130).
- Keep
- Fix selection-mode
Pay $0.00and submenu leaks:- When
secondaryActionsincludesSECONDARY_ACTIONS.PAY,hasPayActionbecomestrueinuseSelectionModeReportActions.ts:207andMoneyReportHeaderSelectionDropdown.tsx:180. - In
MoneyReportHeaderSelectionDropdown.tsx:183-197, passnonPendingDeleteTransactionsinstead ofundefined(lines190and197) tocanIOUBePaidActionsoonlyShowPayElsewherestays accurate. - Both
useSelectionModeReportActions.ts:282-293(line284) andMoneyReportHeaderSelectionDropdown.tsx:293-305(line296) still renderPay $0.00withrightIconandpaymentSubMenuItems. - When
onlyShowPayElsewhere && hasSettledZeroTotal(...)istrue, rendertranslate('iou.payElsewhere', '')(Mark as paid) in both menus and omitrightIcon,backButtonText, andsubMenuItems:- In
MoneyReportHeaderSelectionDropdown.tsx, setonSelectedto callonSelectionModePaymentSelect(undefined, CONST.IOU.PAYMENT_TYPE.ELSEWHERE, () => {})(L204,useSelectionModePayment.ts:351-353), preservingrunPaymentAction(isAccountLockedatuseSelectionModePayment.ts:157-160) andselectPaymentType. - In
useSelectionModeReportActions.ts, setonSelectedto callrunPaymentAction(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, false, () => invokePaymentSelect(undefined, CONST.IOU.PAYMENT_TYPE.ELSEWHERE, () => {}))(L219-L220). PassingdeferBlockingPresentation = falsedirectly avoidsonSelectionModePaymentSelect'sTransitionTracker.runAfterTransitionswrapper (L246-L253) soBulkActionBarButtondoes not wait on a popover transition while still runningisAccountLockedandselectPaymentType.
- In
- When
- Update and add tests:
- Update zero-total assertions in
tests/unit/ReportPrimaryActionUtilsTest.ts:1416-1488(covering both the zero-total non-reimbursable case atL1416-L1452and the cancelling reimbursable case atL1454-L1488) andtests/actions/ReportPreviewActionUtilsTest.ts:1343-1384,L1428-L1474. - Add tests in
tests/unit/ReportSecondaryActionUtilsTest.tsandtests/unit/hooks/useSelectionModeReportActions.test.ts. Verify$0.00reports offer directMark as paid, while positive, non-zero non-reimbursable, and scanning/empty reports preserve existing behavior.
- Update zero-total assertions in
What alternative solutions did you explore? (Optional)
- Rename the primary button to
Mark as paid: If #102215 still governs product behavior,SettlementButton(src/components/SettlementButton/index.tsx:557-562) could renderMark as paidon$0reports. However, that keeps the primary button visible, contradicting this issue's expected result. - Remove
hasSettledZeroReimbursableSpendfromcanIOUBePaid: Rejected because it blocksMark as paidcompletion on settled$0.00reports, regressing #102215.
Contributor: Upwork · [email protected]
— submitted with Antigravity on the contributor's behalf
Contributor details:
- Expensify account email: [email protected]
- Upwork profile: https://www.upwork.com/freelancers/~013b564a690d9bcdab
Proposal
Problem
An approved expense report whose total is $0.00 (for example $50 + -$50) still shows a green primary Pay $0.00 button in the report header and in the chat report preview. The expected behaviour is no Pay button: nothing is owed, and the report should only be closed with Mark as paid.
Root cause
PR #102347 (for #102215) deliberately made $0 reports closable with Mark as paid, by
adding hasSettledZeroReimbursableSpend (src/libs/ReportUtils.ts) to the three Pay
checks: isPrimaryPayAction, canPay, and canIOUBePaid. The same PR added
isPayOptional and excluded these reports from the LHN badge, the Reports row action and
the Pay to-do. But the header primary action and the report preview were never given that
exclusion, so they still render SettlementButton labelled Pay $0.00
(iou.settlePayment) even though the only option in its dropdown is Mark as paid. The
issue is therefore a presentation mismatch: the header and preview disagree with the
rest of the app about a $0 report.
Changes
-
New helper in
src/libs/ReportUtils.ts, next tohasSettledZeroReimbursableSpend:function hasSettledZeroTotal(report, transactions) { const spendBreakdown = getMoneyRequestSpendBreakdown(report); return spendBreakdown.totalDisplaySpend === 0 && hasSettledZeroReimbursableSpend(spendBreakdown, report, transactions); }totalDisplaySpend === 0is the discriminator (notisPayOptional, which is also true for non-reimbursable-only reports with a non-zero total, where the header legitimately shows "Pay $X" - out of scope). It covers a $0 report made of reimbursable expenses that cancel out, a single $0 expense, and a mix of reimbursable/non-reimbursable expenses netting to $0. Fail-closed is inherited:hasSettledZeroReimbursableSpendreturns false while any expense is scanning, failed to scan, or a pending card charge, so a $0 report with an unknown amount keeps its Pay path. -
Report header -
src/libs/ReportPrimaryActionUtils.ts(getReportPrimaryAction): skipPAYwhenhasSettledZeroTotal(report, reportTransactions). The check goes at the call site, not insideisPrimaryPayAction, so the shared predicate keeps its meaning for the More menu and the Pay to-do, which both rely on it. An approved $0 report with a connected integration falls through toEXPORT_TO_ACCOUNTING, otherwise to no primary action - matching the Reports row (View). -
More menu - the report stays closable, with the correct label and the correct guard:
src/libs/ReportSecondaryActionUtils.ts: add the zero-total case togetSecondaryReportActions, soSECONDARY_ACTIONS.PAYis present for $0 reports.src/components/MoneyReportHeaderActions/MoneyReportHeaderSecondaryActions.tsx: when the report is zero-total and only "Mark as paid" applies, render a SINGLE menu item- text
translate('iou.payElsewhere', '')("Mark as paid"), icon Cash, no submenu, no back button.
- text
- Route that item through the existing
onPaymentSelect(which callsselectPaymentTypeand therefore theshouldRestrictUserBillableActionsguard), instead of callingconfirmPaymentdirectly. A direct call would skip the billing-restriction redirect that the submenu path applies today. - Pass the real
nonPendingDeleteTransactions(notundefined) tocanIOUBePaidAction, soonlyShowPayElsewhereis computed from the same transaction list the rest of the header uses. canIOUBePaiditself is NOT changed - the report can still be marked as paid.
-
Report preview -
src/libs/ReportPreviewActionUtils.ts(getReportPreviewAction): same exclusion; a $0 report falls through toEXPORT_TO_ACCOUNTINGif an integration is connected, otherwise toVIEW. TheisPaidAnimationRunning / isApprovedAnimationRunningearly-return is left untouched. -
Selection mode - once the More menu has
SECONDARY_ACTIONS.PAY,hasPayActionbecomes true inuseSelectionModeReportActions.tsandMoneyReportHeaderSelectionDropdown.tsx, so selection mode would still offer Pay $0.00. Apply the same single-item rendering there ("Mark as paid", no submenu), routed throughonSelectionModePaymentSelect/runPaymentActionsoisAccountLockedandselectPaymentTypestill apply.
Not changed: canIOUBePaid, isPayOptional, the LHN badge, the Search row action,
the Pay to-do, isPrimaryPayAction itself, and non-reimbursable-only reports with a
non-zero total (they keep today's behaviour).
Tests
tests/unit/ReportPrimaryActionUtilsTest.ts: flip both $0 tests - the non-reimbursable-only $0 report and the cancel-out $0 report no longer returnPAY. (These are the #102347 regression tests; flipping them is the intended behaviour change for this issue.) Add: a single $0 expense does not return PAY; +$50 reimbursable / -$50 non-reimbursable does not return PAY; +$50/-$50 reimbursable + $100 non-reimbursable (total $100) still returns PAY; a $0 report with a failed-scan expense still does not return PAY (fail-closed, unchanged).tests/actions/ReportPreviewActionUtilsTest.ts: flip both $0 tests - the preview returnsVIEW(orEXPORT_TO_ACCOUNTINGwhere an integration is connected).tests/unit/ReportSecondaryActionUtilsTest.ts: add a case that an approved $0 cancel-out report includesSECONDARY_ACTIONS.PAY, and that a $0 report with a scanning / pending / failed-scan expense does not.tests/actions/IOUTest/ReportWorkflowTest.ts: verify (no change) thatcanIOUBePaidstaystruefor the $0 report - it can still be marked as paid.
Alternatives considered
- Return false from
isPrimaryPayAction/canPay/canIOUBePaidfor $0 reports. Rejected: it would remove the More-menu close-out path as well, leaving the report unclosable - the capability PR #102347 deliberately added. - Reuse
isPayOptionaleverywhere. Rejected: it is also true for non-reimbursable-only reports with a non-zero total, which are out of scope for this issue. - Gate
hasSettledZeroReimbursableSpendonisSecondaryActioninsideisPrimaryPayAction. Rejected:isPrimaryPayActionis a shared predicate used by the header, the More menu and the to-do; mutating its meaning is riskier than a call-site check that changes exactly one surface. - Relabel the primary button to "Mark as paid". Rejected: it keeps a prominent action for a report with nothing to pay, and the header would still disagree with the LHN badge, the Reports row and the to-do.
📣 @dankezo! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~013b564a690d9bcdab
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
I think this is expected behavior from https://github.com/Expensify/App/issues/102215, not a bug
@trjExpensify can you confirm whether we want to keep the current behavior?
Proposal updated: please review this version of my proposal above (https://github.com/Expensify/App/issues/106952#issuecomment-6909279551), reformatted into the official template. The solution and scope are unchanged.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~013b564a690d9bcdab
Please re-state the problem that we are trying to solve in this issue.
An approved expense report whose total is $0.00 (for example $50 + -$50) still shows a green primary Pay $0.00 button in the report header and in the chat report preview. The expected behaviour is no Pay button: nothing is owed, and the report should only be closed with Mark as paid.
What is the root cause of that problem?
PR #102347 (for #102215) deliberately made $0 reports closable with Mark as paid, by
adding hasSettledZeroReimbursableSpend (src/libs/ReportUtils.ts) to the three Pay
checks: isPrimaryPayAction, canPay, and canIOUBePaid. The same PR added
isPayOptional and excluded these reports from the LHN badge, the Reports row action and
the Pay to-do. But the header primary action and the report preview were never given that
exclusion, so they still render SettlementButton labelled Pay $0.00
(iou.settlePayment) even though the only option in its dropdown is Mark as paid. The
issue is therefore a presentation mismatch: the header and preview disagree with the
rest of the app about a $0 report.
What changes do you think we should make in order to solve the problem?
-
New helper in
src/libs/ReportUtils.ts, next tohasSettledZeroReimbursableSpend:function hasSettledZeroTotal(report, transactions) { const spendBreakdown = getMoneyRequestSpendBreakdown(report); return spendBreakdown.totalDisplaySpend === 0 && hasSettledZeroReimbursableSpend(spendBreakdown, report, transactions); }totalDisplaySpend === 0is the discriminator (notisPayOptional, which is also true for non-reimbursable-only reports with a non-zero total, where the header legitimately shows "Pay $X" - out of scope). It covers a $0 report made of reimbursable expenses that cancel out, a single $0 expense, and a mix of reimbursable/non-reimbursable expenses netting to $0. Fail-closed is inherited:hasSettledZeroReimbursableSpendreturns false while any expense is scanning, failed to scan, or a pending card charge, so a $0 report with an unknown amount keeps its Pay path. -
Report header -
src/libs/ReportPrimaryActionUtils.ts(getReportPrimaryAction): skipPAYwhenhasSettledZeroTotal(report, reportTransactions). The check goes at the call site, not insideisPrimaryPayAction, so the shared predicate keeps its meaning for the More menu and the Pay to-do, which both rely on it. An approved $0 report with a connected integration falls through toEXPORT_TO_ACCOUNTING, otherwise to no primary action - matching the Reports row (View). -
More menu - the report stays closable, with the correct label and the correct guard:
src/libs/ReportSecondaryActionUtils.ts: add the zero-total case togetSecondaryReportActions, soSECONDARY_ACTIONS.PAYis present for $0 reports.src/components/MoneyReportHeaderActions/MoneyReportHeaderSecondaryActions.tsx: when the report is zero-total and only "Mark as paid" applies, render a SINGLE menu item- text
translate('iou.payElsewhere', '')("Mark as paid"), icon Cash, no submenu, no back button.
- text
- Route that item through the existing
onPaymentSelect(which callsselectPaymentTypeand therefore theshouldRestrictUserBillableActionsguard), instead of callingconfirmPaymentdirectly. A direct call would skip the billing-restriction redirect that the submenu path applies today. - Pass the real
nonPendingDeleteTransactions(notundefined) tocanIOUBePaidAction, soonlyShowPayElsewhereis computed from the same transaction list the rest of the header uses. canIOUBePaiditself is NOT changed - the report can still be marked as paid.
-
Report preview -
src/libs/ReportPreviewActionUtils.ts(getReportPreviewAction): same exclusion; a $0 report falls through toEXPORT_TO_ACCOUNTINGif an integration is connected, otherwise toVIEW. TheisPaidAnimationRunning / isApprovedAnimationRunningearly-return is left untouched. -
Selection mode - once the More menu has
SECONDARY_ACTIONS.PAY,hasPayActionbecomes true inuseSelectionModeReportActions.tsandMoneyReportHeaderSelectionDropdown.tsx, so selection mode would still offer Pay $0.00. Apply the same single-item rendering there ("Mark as paid", no submenu), routed throughonSelectionModePaymentSelect/runPaymentActionsoisAccountLockedandselectPaymentTypestill apply.
Not changed: canIOUBePaid, isPayOptional, the LHN badge, the Search row action,
the Pay to-do, isPrimaryPayAction itself, and non-reimbursable-only reports with a
non-zero total (they keep today's behaviour).
Tests:
tests/unit/ReportPrimaryActionUtilsTest.ts: flip both $0 tests - the non-reimbursable-only $0 report and the cancel-out $0 report no longer returnPAY. (These are the #102347 regression tests; flipping them is the intended behaviour change for this issue.) Add: a single $0 expense does not return PAY; +$50 reimbursable / -$50 non-reimbursable does not return PAY; +$50/-$50 reimbursable + $100 non-reimbursable (total $100) still returns PAY; a $0 report with a failed-scan expense still does not return PAY (fail-closed, unchanged).tests/actions/ReportPreviewActionUtilsTest.ts: flip both $0 tests - the preview returnsVIEW(orEXPORT_TO_ACCOUNTINGwhere an integration is connected).tests/unit/ReportSecondaryActionUtilsTest.ts: add a case that an approved $0 cancel-out report includesSECONDARY_ACTIONS.PAY, and that a $0 report with a scanning / pending / failed-scan expense does not.tests/actions/IOUTest/ReportWorkflowTest.ts: verify (no change) thatcanIOUBePaidstaystruefor the $0 report - it can still be marked as paid.
What alternative solutions did you explore? (Optional)
- Return false from
isPrimaryPayAction/canPay/canIOUBePaidfor $0 reports. Rejected: it would remove the More-menu close-out path as well, leaving the report unclosable - the capability PR #102347 deliberately added. - Reuse
isPayOptionaleverywhere. Rejected: it is also true for non-reimbursable-only reports with a non-zero total, which are out of scope for this issue. - Gate
hasSettledZeroReimbursableSpendonisSecondaryActioninsideisPrimaryPayAction. Rejected:isPrimaryPayActionis a shared predicate used by the header, the More menu and the to-do; mutating its meaning is riskier than a call-site check that changes exactly one surface. - Relabel the primary button to "Mark as paid". Rejected: it keeps a prominent action for a report with nothing to pay, and the header would still disagree with the LHN badge, the Reports row and the to-do.
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
I think this is expected behavior from https://github.com/Expensify/App/issues/102215, not a bug
@trjExpensify can you confirm whether we want to keep the current behavior?
The video in the OP didn't show the options, but if the pay option available is Mark as paid only that's expected. People can manually mark a balanced report as paid. CC: @joekaufmanexpensify
@daledah Whoops! This issue is 2 days overdue. Let's get this updated quick!
@daledah Still overdue 6 days?! Let's take care of this!
@joekaufmanexpensify could you please check this comment?
Yep, Tom is correct. We intentionally added support for showing mark as paid on a balanced report in this issue.
Not a bug, so we can close this issue