Repository navigation
Closed
Labels
Awaiting PaymentAuto-added when associated PR is deployed to productionAuto-added when associated PR is deployed to productionDailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributor
Description
Problem
When a report is marked as paid ("paid elsewhere" / manual reimbursement) in NewDot, admins have no way to reverse that to edit the report. There is currently a gap: once a report is marked as paid, it's effectively locked, even though no real money moved.
In Classic, admins can Unapprove a manually-paid report, which reverts it all the way to Outstanding (returning to the last approver).
Proposed solution
Add a Cancel payment action for manually-paid reports in NewDot, giving admins a cleaner recovery path:
- Cancel payment on a marked-as-paid report → returns the report to its pre-payment state so the admin can re-pay or change approver without redoing the approval chain. The exact state depends on the workspace's approval workflow:
- It'll go back to Approved if approvals are enabled on the workflow
- It'll go back to Done if approvals are not enabled
- From there, Unapprove → Outstanding to make edits, or Change approver to reapprove / re-mark as paid as necessary.
Surfacing Cancel payment (rather than only Unapprove-straight-to-Outstanding) gives admins finer control, since returning to Approved/Processing/Done is a less destructive intermediate state than jumping straight to Outstanding.
Why this is NewDot-only / low risk
- The action gating for NewDot is decided client-side in App (
src/libs/ReportSecondaryActionUtils.ts—isCancelPaymentAction/isUnapproveAction). Classic computes its own action availability separately, so a NewDot-only client change does not affect Classic behavior. - The backend already supports reverting a manual ("elsewhere") payment back to its pre-payment state without moving any money — no new backend logic is required for the core flow.
Scope / things to nail down
- Confirm and, if needed, repair the
isCancelPaymentActiongating so Cancel payment reliably surfaces on manually-paid reports for the admin/payer. (At current HEAD this predicate appears to already returntruefor a manually-paid report when the user is admin+payer — so the production gap may be a bug in the predicate rather than a missing feature. Worth confirming a repro first.) - Account for approval-workflow / policy-mode variations in the resulting state after cancel:
- Standard submit-and-approve (and non-optional instant-submit): → Approved (the common case)
- Multi-level / advanced approval workflows: → Processing or Done depending on where the report sits in the chain
- Optional-approval workspace: → Approved state but Closed status
- Instant-submit + optional-approval: → Outstanding (Submitted)
Make sure the UX/copy handles the cases where the report does not land on Approved.
- No changes to Classic or shared backend gating probes.
Reported in Slack.
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022083186701741562188
- Upwork Job ID: 2083186701741562188
- Last Price Increase: 2026-07-31
Issue Owner
Current Issue Owner: @shubham1206agraMetadata
Metadata
Labels
Awaiting PaymentAuto-added when associated PR is deployed to productionAuto-added when associated PR is deployed to productionDailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributor
Type
Projects
- StatusShow more project fieldsDone
Activity
melvin-bot commentedon Jul 31, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @shubham1206agra (
External)melvin-bot commentedon Jul 31, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022083186701741562188
samranahm commentedon Jul 31, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-07-31 15:42:08 UTC.
Proposal
What is the root cause of that problem?
When an admin cancels a manual ("paid elsewhere") payment in NewDot, the optimistic report status often does not match the state the report was in immediately before it was marked as paid. The header, next step, and secondary actions then show the wrong recovery path until the server responds, and offline the wrong state sticks for the whole session.
Mark as paid always overwrites that pair to Approved + Reimbursed (
2/4), so Approved-before-pay and Done-before-pay become identical once paid:App/src/libs/actions/IOU/PayMoneyRequest.ts
Lines 337 to 338 in e32ef22
At cancel time,
cancelPaymenttries to rebuild the destination frompolicy.approvalModealone. It hard-codesstateNumtoAPPROVED, and only switchesstatusNumbetweenAPPROVEDandCLOSED:App/src/libs/actions/IOU/PayMoneyRequest.ts
Lines 538 to 541 in e32ef22
That binary guess is incomplete for the real pre-payment workflows:
2/3).2/2).1/1) and can be marked paid from there. Cancel must land on Outstanding, not Done or Approved.Case 3 is already how NewDot creates expense reports under instant submit.
getExpenseReportStateAndStatusreturns Submitted/Submitted when instant submit is on:App/src/libs/ReportUtils.ts
Lines 7058 to 7063 in e32ef22
App/src/libs/PolicyUtils.ts
Lines 1510 to 1512 in e32ef22
Both case 2 and case 3 use optional approval (
isSubmitAndClose), soapprovalModealone cannot tell Done apart from Outstanding:App/src/libs/PolicyUtils.ts
Lines 1547 to 1549 in e32ef22
Because cancel never reads submission frequency, an instant-submit + approvals-disabled report that was paid from Outstanding optimistically jumps to Done/Approved instead of returning to Outstanding.
What changes do you think we should make in order to solve the problem?
App/src/libs/ReportUtils.ts
Lines 7039 to 7069 in e32ef22
APPROVED/APPROVED(Approved)APPROVED/CLOSED(Done)SUBMITTED/SUBMITTED(Outstanding)APPROVED/APPROVED(Approved)This mirrors the pre-payment workflow NewDot already uses, including the instant-submit Outstanding behavior, without inventing a new persisted field and without walking report action history.
cancelPayment, replace theapprovalMode-onlystateNum/statusNumassignment with that helper:App/src/libs/actions/IOU/PayMoneyRequest.ts
Lines 517 to 547 in e32ef22
Keep the existing next-step bank-account special case for Done restores: when the restored
statusNumisCLOSEDand the workspace has a connected bank account, keep predicting next status asSUBMITTEDso copy still says waiting to pay. Outstanding restores already useSUBMITTED, so that override is a no-op there. Parent previewchildStateNum/childStatusNumcontinue to use the same restored pair.What alternative solutions did you explore? (Optional)
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
Test Branch
Solution Verification Result
Mark.as.paid.mp4
lorretheboy commentedon Jul 31, 2026
Proposal
What is the root cause of that problem?
The "Mark as paid" button and the "Cancel payment" option are gated by
isPayercalled with different values ofonlyShowPayElsewhere, so the same admin who marked a report as paid doesn't qualify to cancel that payment.Marking as paid is offered through
canIOUBePaid(..., onlyShowPayElsewhere = true):App/src/libs/actions/IOU/ReportWorkflow.ts
Line 235 in b39154f
and with that flag,
isPayerexplicitly allows any admin on a workspace whose reimbursement is disabled (REIMBURSEMENT_NO— the typical mark-as-paid-only workspace):App/src/libs/ReportUtils.ts
Lines 2843 to 2855 in b39154f
But
isCancelPaymentActioncallsisPayerwith the flag hard-coded tofalse, and bails out if it returns false:App/src/libs/ReportSecondaryActionUtils.ts
Lines 415 to 420 in b39154f
With
onlyShowPayElsewhere = false, theREIMBURSEMENT_NOworkspace falls into the "reimbursement is disabled → return false" branch. Chain: admin marks report as paid (allowed via the pay-elsewhere payer check) → report becomes Approved/Reimbursed →isCancelPaymentActionre-checks payer withfalse→isPayerreturns false because reimbursement is disabled → the function never reaches its paid-elsewhere branch (which would correctly returntrue) → Cancel payment never appears → the report is locked.The
cancelPaymentaction itself already reverts a paid-elsewhere report to the correct pre-payment state (Approved, or Closed for optional-approval mode), so only the gating is broken:App/src/libs/actions/IOU/PayMoneyRequest.ts
Lines 558 to 561 in b39154f
What changes do you think we should make in order to solve the problem?
In
isCancelPaymentAction, mirror the gating that surfaced the payment in the first place: move the existingisPaidViaBankAccountcomputation above the admin/payer check, and pass!isPaidViaBankAccountasisPayer'sonlyShowPayElsewhereargument:For a report paid via bank account nothing changes (flag stays
false), and for a manually-paid report the payer check now matches the one that allowed "Mark as paid", so admins on reimbursement-disabled workspaces can cancel. TheisAdminrequirement already in the function keeps this admin-only, and the existing paid-elsewhere branch (stateNum === APPROVED && statusNum === REIMBURSED && !isPaidViaBankAccount) then returnstrueas intended:App/src/libs/ReportSecondaryActionUtils.ts
Lines 430 to 440 in b39154f
This is NewDot-only client gating; Classic and backend are untouched.
What alternative solutions did you explore? (Optional)
Skip the
isPayercheck entirely for manually-paid reports and rely onisAdminalone. Simpler, but reusingisPayerwith the pay-elsewhere flag keeps "who can cancel" symmetric with "who could pay", which also covers designated-reimburser edge cases consistently.[-]Allow admins to Cancel payment on manually-paid (marked as paid) reports in NewDot[/-][+][$250] Allow admins to Cancel payment on manually-paid (marked as paid) reports in NewDot[/+]wildan-m commentedon Jul 31, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
Once an expense report is marked as paid manually ("paid elsewhere") in NewDot, an admin has no way to reverse it — Cancel payment does not surface in the report's secondary actions, so the report is effectively locked even though no real money moved.
What is the root cause of that problem?
The gating for Cancel payment is stricter than the gating for the Pay / Mark as paid action it is supposed to reverse, so the very admin who marked the report as paid is not allowed to cancel it.
isCancelPaymentActiondecides payer eligibility by callingisPayerwithonlyShowPayElsewhereexplicitly set tofalse:App/src/libs/ReportSecondaryActionUtils.ts
Lines 415 to 420 in 80e8347
Inside
isPayer, that flag is what allows an admin to act on a workspace where reimbursement is turned off. WithonlyShowPayElsewherefalse, a workspace whosereimbursementChoiceisREIMBURSEMENT_NOfalls through to the "reimbursement is disabled for this workspace" branch and returnsfalseunconditionally:App/src/libs/ReportUtils.ts
Lines 2843 to 2855 in 80e8347
The pay side deliberately does the opposite.
canIOUBePaidallows aREIMBURSEMENT_NOworkspace through only whenonlyShowPayElsewhereis true, and passes that same flag down toisPayer, which then returnsisAdmin:App/src/libs/actions/IOU/ReportWorkflow.ts
Lines 215 to 236 in 80e8347
So on exactly the workspaces where reports get manually marked as paid — reimbursement disabled, admin uses "Mark as paid" — the admin passes the pay check and fails the cancel check.
isCancelPaymentActionreturnsfalseat the!isAdmin || !isPayerguard and never reaches the branch that is already written to handle elsewhere-payments:App/src/libs/ReportSecondaryActionUtils.ts
Lines 428 to 440 in 80e8347
The rest of the flow is already correct and does not need new logic. Marking as paid always moves the report to
stateNumAPPROVED /statusNumREIMBURSED, which is the state that branch tests for, andcancelPaymentalready computes the correct post-cancel state per workspace configuration — back to Approved normally, and Closed when the approval mode is optional:App/src/libs/actions/IOU/PayMoneyRequest.ts
Lines 558 to 561 in 80e8347
What changes do you think we should make in order to solve the problem?
In
isCancelPaymentAction, make the payer check use the same semantics as the payment being cancelled, instead of always using the stricter bank-payment semantics.Concretely, move the existing computation of the report's pay actions and the
isPaidViaBankAccountflag above the payer guard, and derive the payer check from it: when the payment being cancelled was made elsewhere (not via a bank account), callisPayerwithonlyShowPayElsewhereset totrue; when it was a bank payment, keep passingfalseso cancelling an in-flight ACH payment still requires real reimburser/bank rights. TheisAdminguard directly above stays exactly as it is, so this only ever admits workspace admins — the same people the pay-elsewhere path already admits.This is a one-for-one alignment with the pay path: whoever is allowed to mark a report as paid elsewhere becomes allowed to cancel that same payment, and nothing changes for bank-account payments, invoices, or non-admins. Because
cancelPaymentalready derives the destination state from the workspace's approval mode, the resulting state after cancelling behaves as the issue describes — Approved when approvals are enabled, Closed under optional approval — with no extra work needed, and from there the existing Unapprove action takes the report back to Outstanding for editing.Worth noting for the follow-up scope in the issue: the multi-level / advanced-approval variations listed there are decided by
cancelPayment's existing state computation and by the backend response, not by this predicate, so they are unaffected by this gating fix.Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/97577-cancel-payment-elsewhere-payer?expand=1
What alternative solutions did you explore? (Optional)
Relaxing the guard in
isCancelPaymentActionto accept any workspace admin regardless of theisPayerresult. This surfaces the action in the reported scenario too, but it is too broad — it would also expose Cancel payment to admins who are not the designated reimburser on manual-reimbursement workspaces and to admins without bank-account access on auto-reimbursement workspaces, i.e. people who cannot make that payment in the first place. Deriving the flag from the payment type keeps the cancel permission exactly as wide as the pay permission.Changing
isPayeritself so the disabled-reimbursement branch returnsisAdminregardless ofonlyShowPayElsewhere. This would fix the symptom in one line, butisPayeris shared by the primary pay action, the report preview action and the next-step copy, so it would silently widen who is treated as the payer across several unrelated surfaces. Keeping the change local to the cancel predicate avoids that blast radius.wildan-m commentedon Jul 31, 2026
Proposal updated — added compare branch with implementation.
trasnake87 commentedon Jul 31, 2026
Proposal
What is the root cause of that problem?
isCancelPaymentActionhard-codesonlyShowPayElsewhere = falsein itsisPayercall:App/src/libs/ReportSecondaryActionUtils.ts
Lines 415 to 420 in 5d21950
But the "mark as paid" gate is actually two parallel paths, and
isCancelPaymentActionblocks on both of them — not just one:Path A —
REIMBURSEMENT_NOworkspaces (the classic "mark as paid only" policy).isPayeronly lets an admin through on a payments-disabled policy whenonlyShowPayElsewhereistrue. Withfalse, the function returns early inside the "reimbursement is disabled for this workspace" branch before reaching the paid-elsewhere logic:App/src/libs/ReportUtils.ts
Lines 2844 to 2856 in 5d21950
The pay side deliberately sets the flag to
truethroughcanIOUBePaid, which letsREIMBURSEMENT_NOadmins mark reports as paid. The cancel side does the opposite, so the same admin cannot reverse their own action.Path B — manual reimbursement with a non-reimburser admin. Both primary and secondary pay buttons OR
isPayertogether with aWORKFLOWS_PAYMENTSwrite check, so any admin with payments write access can mark as paid even if they are not the designated reimburser:App/src/libs/actions/IOU/ReportWorkflow.ts
Lines 234 to 238 in 5d21950
App/src/libs/ReportPrimaryActionUtils.ts
Lines 222 to 227 in 5d21950
isCancelPaymentActionhas no equivalent widening, so a non-reimburser admin who marked the report paid via theWORKFLOWS_PAYMENTSpath is also blocked from cancelling.There is a second independent defect in scope item 2:
cancelPaymenthard-codes the reverted state toAPPROVED/APPROVED:App/src/libs/actions/IOU/PayMoneyRequest.ts
Lines 558 to 561 in 5d21950
An instant-submit + optional-approval report never passed through Approved on its way to being paid, so cancelling should return it to Outstanding (
SUBMITTED/SUBMITTED), not Approved. The mismatch means the optimistic update briefly shows an Unapprove action on a report that is actually Outstanding.What changes do you think we should make in order to solve the problem?
1.
src/libs/ReportSecondaryActionUtils.ts(lines 415-420) — mirror the pay gate's full payer logic.canMemberWriteis already imported in this file:Passing
arePaymentsDisabledrather than a blankettrueis intentional: it unlocks Path A while leaving the reimburser/bank-account branch ofisPayerintact for the NACHA-cutoff bank-cancel path. TheWORKFLOWS_PAYMENTSOR handles Path B.2.
src/libs/actions/IOU/PayMoneyRequest.ts(lines 560-561) — derive the reverted state from policy configuration, matching the branch logic already present ingetExpenseReportStateAndStatus:App/src/libs/ReportUtils.ts
Lines 7017 to 7033 in 5d21950
Add
isInstantSubmitEnabledandarePaymentsEnabledto the existing@libs/PolicyUtilsimport.predictedNextStatusderives fromstatusNum, so the next-step copy reflects the real landing state rather than always reading as Approved.Restoring this proposal — it was auto-flagged as a duplicate of an earlier proposal, but the analysis differs materially: Ours adds Path B (non-reimburser admin via WORKFLOWS_PAYMENTS) and cancelPayment wrong-state reversion bug THEIRS omits.
github-actions commentedon Jul 31, 2026
92 remaining items
melvin-bot commentedon Sep 8, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Sep 8, 2026
Payment Summary
Resolving PRs:
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Sep 10, 2026
Payment Summary
Contributor: @dilshodmackbook-sketch paid $250 via Upwork
Contributor+: @shubham1206agra due $250 via NewDot
@dilshodmackbook-sketch can you please accept the job below? Please reply here and tag me once you have.
https://www.upwork.com/jobs/~022098076571937590777
David-2002065 commentedon Sep 10, 2026
@mallenexpensify accepted thanks.
mallenexpensify commentedon Sep 12, 2026
@dilshodmackbook-sketch paid, summary updated above. Thx.
[-][Due for payment 2026-09-09] [CFI] [$250] Allow admins to Cancel payment on manually-paid (marked as paid) reports in NewDot[/-][+][Due for payment 2026-10-01] [CFI] [$250] Allow admins to Cancel payment on manually-paid (marked as paid) reports in NewDot[/+]melvin-bot commentedon Sep 24, 2026
@shubham1206agra @mallenexpensify
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.92-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-10-01. 🎊
The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]