Skip to content

[Due for payment 2026-10-01] [CFI] [$250] Allow admins to Cancel payment on manually-paid (marked as paid) reports in NewDot #97577

Closed

Description

@melvin-bot

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

  1. Confirm and, if needed, repair the isCancelPaymentAction gating so Cancel payment reliably surfaces on manually-paid reports for the admin/payer. (At current HEAD this predicate appears to already return true for 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.)
  2. 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.
  3. No changes to Classic or shared backend gating probes.

Reported in Slack.

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @shubham1206agra

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 31, 2026
  2. melvin-bot commented on Jul 31, 2026

    @melvin-bot
    Author

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @shubham1206agra (External)

  3. melvin-bot commented on Jul 31, 2026

    @melvin-bot
    Author
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 31, 2026
  5. samranahm commented on Jul 31, 2026

    @samranahm
    Contributor

    🚨 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:

    statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED,
    stateNum: CONST.REPORT.STATE_NUM.APPROVED,

    At cancel time, cancelPayment tries to rebuild the destination from policy.approvalMode alone. It hard-codes stateNum to APPROVED, and only switches statusNum between APPROVED and CLOSED:

    const approvalMode = policy?.approvalMode ?? CONST.POLICY.APPROVAL_MODE.BASIC;
    const stateNum: ValueOf<typeof CONST.REPORT.STATE_NUM> = CONST.REPORT.STATE_NUM.APPROVED;
    const statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.APPROVED;

    That binary guess is incomplete for the real pre-payment workflows:

    1. Approvals enabled, submission not instant: Draft to Outstanding to Approved to Paid. Cancel must land on Approved (2/3).
    2. Approvals disabled, submission not instant: Draft to Done to Paid. Cancel must land on Done (2/2).
    3. Approvals disabled, submission instant: the report is created as Outstanding (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. getExpenseReportStateAndStatus returns Submitted/Submitted when instant submit is on:

    App/src/libs/ReportUtils.ts

    Lines 7058 to 7063 in e32ef22

    if (isInstantSubmitEnabledLocal && !(isSubmitAndCloseLocal && isEmptyOptimisticReport)) {
    return {
    stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
    statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
    };
    }

    App/src/libs/PolicyUtils.ts

    Lines 1510 to 1512 in e32ef22

    function isInstantSubmitEnabled(policy: OnyxInputOrEntry<Policy>): boolean {
    return policy?.autoReporting === true && policy?.autoReportingFrequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT;
    }

    Both case 2 and case 3 use optional approval (isSubmitAndClose), so approvalMode alone cannot tell Done apart from Outstanding:

    App/src/libs/PolicyUtils.ts

    Lines 1547 to 1549 in e32ef22

    function isSubmitAndClose(policy: OnyxInputOrEntry<Policy>): boolean {
    return policy?.approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL;
    }

    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?

    1. Add a helper that maps the workspace's approval mode and submission frequency to the cancel restore pair.
    function getReportStateAndStatusAfterCancelPayment(policy: OnyxEntry<Policy>): {
        stateNum: ValueOf<typeof CONST.REPORT.STATE_NUM>;
        statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM>;
    } {
        const areApprovalsDisabled = isSubmitAndClose(policy);
        const isInstantSubmit = isInstantSubmitEnabled(policy);
    
        if (areApprovalsDisabled && isInstantSubmit) {
            return {
                stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
                statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
            };
        }
    
        if (areApprovalsDisabled) {
            return {
                stateNum: CONST.REPORT.STATE_NUM.APPROVED,
                statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
            };
        }
    
        return {
            stateNum: CONST.REPORT.STATE_NUM.APPROVED,
            statusNum: CONST.REPORT.STATUS_NUM.APPROVED,
        };
    }

    App/src/libs/ReportUtils.ts

    Lines 7039 to 7069 in e32ef22

    function getExpenseReportStateAndStatus(policy: OnyxEntry<Policy>, betas: OnyxEntry<Beta[]>, isEmptyOptimisticReport = false) {
    const isASAPSubmitBetaEnabled = Permissions.isBetaEnabled(CONST.BETAS.ASAP_SUBMIT, betas);
    if (isASAPSubmitBetaEnabled) {
    return {
    stateNum: CONST.REPORT.STATE_NUM.OPEN,
    statusNum: CONST.REPORT.STATUS_NUM.OPEN,
    };
    }
    const isInstantSubmitEnabledLocal = isInstantSubmitEnabled(policy);
    const isSubmitAndCloseLocal = isSubmitAndClose(policy);
    const arePaymentsDisabled = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO;
    if (isInstantSubmitEnabledLocal && arePaymentsDisabled && isSubmitAndCloseLocal && !isEmptyOptimisticReport) {
    return {
    stateNum: CONST.REPORT.STATE_NUM.APPROVED,
    statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
    };
    }
    if (isInstantSubmitEnabledLocal && !(isSubmitAndCloseLocal && isEmptyOptimisticReport)) {
    return {
    stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
    statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
    };
    }
    return {
    stateNum: CONST.REPORT.STATE_NUM.OPEN,
    statusNum: CONST.REPORT.STATUS_NUM.OPEN,
    };
    }

    • Approvals enabled (not submit-and-close): APPROVED / APPROVED (Approved)
    • Approvals disabled + not instant: APPROVED / CLOSED (Done)
    • Approvals disabled + instant: SUBMITTED / SUBMITTED (Outstanding)
    • Approvals enabled + instant: 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.

    1. In cancelPayment, replace the approvalMode-only stateNum/statusNum assignment with that helper:

    function cancelPayment(
    expenseReport: OnyxEntry<OnyxTypes.Report>,
    chatReport: OnyxTypes.Report,
    policy: OnyxEntry<OnyxTypes.Policy>,
    isASAPSubmitBetaEnabled: boolean,
    currentUserAccountIDParam: number,
    currentUserEmailParam: string,
    hasViolations: boolean,
    isTrackIntentUser: boolean | undefined,
    ) {
    if (isEmptyObject(expenseReport)) {
    return;
    }
    // Prefer the freshly computed reimbursableTotal over deriving from the (sometimes stale) stored total.
    const optimisticReportAction = buildOptimisticCancelPaymentReportAction(
    expenseReport.reportID,
    -getReimbursableTotal(expenseReport),
    expenseReport.currency ?? '',
    currentUserAccountIDParam,
    );
    const approvalMode = policy?.approvalMode ?? CONST.POLICY.APPROVAL_MODE.BASIC;
    const stateNum: ValueOf<typeof CONST.REPORT.STATE_NUM> = CONST.REPORT.STATE_NUM.APPROVED;
    const statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.APPROVED;
    // For OPTIONAL approval mode with a connected bank account, the report status is CLOSED but the next step
    // should show "waiting to pay", so we use SUBMITTED as the predictedNextStatus which routes through the
    // correct next step path. Without a bank account, keep CLOSED which shows "no further action required".
    const hasConnectedBankAccount = !!policy?.achAccount?.accountNumber;
    const predictedNextStatus = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL && hasConnectedBankAccount ? CONST.REPORT.STATUS_NUM.SUBMITTED : statusNum;

    Keep the existing next-step bank-account special case for Done restores: when the restored statusNum is CLOSED and the workspace has a connected bank account, keep predicting next status as SUBMITTED so copy still says waiting to pay. Outstanding restores already use SUBMITTED, so that override is a no-op there. Parent preview childStateNum/childStatusNum continue 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
  6. lorretheboy commented on Jul 31, 2026

    @lorretheboy
    Contributor

    Proposal

    What is the root cause of that problem?

    The "Mark as paid" button and the "Cancel payment" option are gated by isPayer called with different values of onlyShowPayElsewhere, 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):

    const isReportPayer = isPayerReportUtils(currentUserAccountID, currentUserLogin, iouReport, bankAccountList, policy, onlyShowPayElsewhere);

    and with that flag, isPayer explicitly 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

    if (isPaidGroupPolicy(iouReport)) {
    // Pay-elsewhere / mark-paid flows for disabled reimbursement still allow any admin to act.
    if (onlyShowPayElsewhere && reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) {
    return isAdmin;
    }
    const isAutoReimbursement = reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES;
    const isManualReimbursement = reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL;
    // Reimbursement is disabled for this workspace.
    if (!isAutoReimbursement && !isManualReimbursement) {
    return false;
    }

    But isCancelPaymentAction calls isPayer with the flag hard-coded to false, and bails out if it returns false:

    const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;
    const isPayer = isPayerUtils(currentAccountID, currentUserEmail, report, bankAccountList, policy, false);
    if (!isAdmin || !isPayer) {
    return false;
    }

    With onlyShowPayElsewhere = false, the REIMBURSEMENT_NO workspace 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 → isCancelPaymentAction re-checks payer with false → isPayer returns false because reimbursement is disabled → the function never reaches its paid-elsewhere branch (which would correctly return true) → Cancel payment never appears → the report is locked.

    The cancelPayment action 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:

    const approvalMode = policy?.approvalMode ?? CONST.POLICY.APPROVAL_MODE.BASIC;
    const stateNum: ValueOf<typeof CONST.REPORT.STATE_NUM> = CONST.REPORT.STATE_NUM.APPROVED;
    const statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.APPROVED;

    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 existing isPaidViaBankAccount computation above the admin/payer check, and pass !isPaidViaBankAccount as isPayer's onlyShowPayElsewhere argument:

    const isPayer = isPayerUtils(currentAccountID, currentUserEmail, report, bankAccountList, policy, !isPaidViaBankAccount);

    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. The isAdmin requirement already in the function keeps this admin-only, and the existing paid-elsewhere branch (stateNum === APPROVED && statusNum === REIMBURSED && !isPaidViaBankAccount) then returns true as intended:

    const isPaidViaBankAccount =
    payActions.length > 0 &&
    payActions.every((action) => {
    const originalMessage = getOriginalMessage(action);
    return originalMessage && 'paymentType' in originalMessage && originalMessage.paymentType !== CONST.IOU.PAYMENT_TYPE.ELSEWHERE;
    });
    // For reports marked as paid elsewhere or when we can't determine payment type, show cancel button
    if (report.stateNum === CONST.REPORT.STATE_NUM.APPROVED && report.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED && !isPaidViaBankAccount) {
    return true;
    }

    This is NewDot-only client gating; Classic and backend are untouched.

    What alternative solutions did you explore? (Optional)

    Skip the isPayer check entirely for manually-paid reports and rely on isAdmin alone. Simpler, but reusing isPayer with the pay-elsewhere flag keeps "who can cancel" symmetric with "who could pay", which also covers designated-reimburser edge cases consistently.

  7. changed the title [-]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[/+] on Jul 31, 2026
  8. wildan-m commented on Jul 31, 2026

    @wildan-m
    Contributor

    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.

    isCancelPaymentAction decides payer eligibility by calling isPayer with onlyShowPayElsewhere explicitly set to false:

    const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;
    const isPayer = isPayerUtils(currentAccountID, currentUserEmail, report, bankAccountList, policy, false);
    if (!isAdmin || !isPayer) {
    return false;
    }

    Inside isPayer, that flag is what allows an admin to act on a workspace where reimbursement is turned off. With onlyShowPayElsewhere false, a workspace whose reimbursementChoice is REIMBURSEMENT_NO falls through to the "reimbursement is disabled for this workspace" branch and returns false unconditionally:

    App/src/libs/ReportUtils.ts

    Lines 2843 to 2855 in 80e8347

    if (isPaidGroupPolicy(iouReport)) {
    // Pay-elsewhere / mark-paid flows for disabled reimbursement still allow any admin to act.
    if (onlyShowPayElsewhere && reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) {
    return isAdmin;
    }
    const isAutoReimbursement = reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES;
    const isManualReimbursement = reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL;
    // Reimbursement is disabled for this workspace.
    if (!isAutoReimbursement && !isManualReimbursement) {
    return false;
    }

    The pay side deliberately does the opposite. canIOUBePaid allows a REIMBURSEMENT_NO workspace through only when onlyShowPayElsewhere is true, and passes that same flag down to isPayer, which then returns isAdmin:

    if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) {
    if (!onlyShowPayElsewhere) {
    return false;
    }
    if (iouReport?.statusNum !== CONST.REPORT.STATUS_NUM.SUBMITTED) {
    return false;
    }
    }
    if (isInvoiceReportReportUtils(iouReport)) {
    if (isChatReportArchived || iouSettled || isOpenInvoiceReportReportUtils(iouReport)) {
    return false;
    }
    if (chatReport?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL) {
    return chatReport?.invoiceReceiver?.accountID === currentUserAccountID;
    }
    return invoiceReceiverPolicy?.role === CONST.POLICY.ROLE.ADMIN;
    }
    const isReportPayer = isPayerReportUtils(currentUserAccountID, currentUserLogin, iouReport, bankAccountList, policy, onlyShowPayElsewhere);
    const canPay =

    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. isCancelPaymentAction returns false at the !isAdmin || !isPayer guard and never reaches the branch that is already written to handle elsewhere-payments:

    // Check if payment was made via bank account (not elsewhere)
    // If no pay actions exist, we can't determine the payment type, so we assume it was NOT a bank payment
    const isPaidViaBankAccount =
    payActions.length > 0 &&
    payActions.every((action) => {
    const originalMessage = getOriginalMessage(action);
    return originalMessage && 'paymentType' in originalMessage && originalMessage.paymentType !== CONST.IOU.PAYMENT_TYPE.ELSEWHERE;
    });
    // For reports marked as paid elsewhere or when we can't determine payment type, show cancel button
    if (report.stateNum === CONST.REPORT.STATE_NUM.APPROVED && report.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED && !isPaidViaBankAccount) {
    return true;
    }

    The rest of the flow is already correct and does not need new logic. Marking as paid always moves the report to stateNum APPROVED / statusNum REIMBURSED, which is the state that branch tests for, and cancelPayment already computes the correct post-cancel state per workspace configuration — back to Approved normally, and Closed when the approval mode is optional:

    const approvalMode = policy?.approvalMode ?? CONST.POLICY.APPROVAL_MODE.BASIC;
    const stateNum: ValueOf<typeof CONST.REPORT.STATE_NUM> = CONST.REPORT.STATE_NUM.APPROVED;
    const statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.APPROVED;

    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 isPaidViaBankAccount flag above the payer guard, and derive the payer check from it: when the payment being cancelled was made elsewhere (not via a bank account), call isPayer with onlyShowPayElsewhere set to true; when it was a bank payment, keep passing false so cancelling an in-flight ACH payment still requires real reimburser/bank rights. The isAdmin guard 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 cancelPayment already 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 isCancelPaymentAction to accept any workspace admin regardless of the isPayer result. 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 isPayer itself so the disabled-reimbursement branch returns isAdmin regardless of onlyShowPayElsewhere. This would fix the symptom in one line, but isPayer is 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.

  9. wildan-m commented on Jul 31, 2026

    @wildan-m
    Contributor

    Proposal updated — added compare branch with implementation.

  10. trasnake87 commented on Jul 31, 2026

    @trasnake87
    Contributor

    Proposal

    What is the root cause of that problem?

    isCancelPaymentAction hard-codes onlyShowPayElsewhere = false in its isPayer call:

    const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;
    const isPayer = isPayerUtils(currentAccountID, currentUserEmail, report, bankAccountList, policy, false);
    if (!isAdmin || !isPayer) {
    return false;
    }

    But the "mark as paid" gate is actually two parallel paths, and isCancelPaymentAction blocks on both of them — not just one:

    Path A — REIMBURSEMENT_NO workspaces (the classic "mark as paid only" policy). isPayer only lets an admin through on a payments-disabled policy when onlyShowPayElsewhere is true. With false, 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

    if (isPaidGroupPolicy(iouReport)) {
    // Pay-elsewhere / mark-paid flows for disabled reimbursement still allow any admin to act.
    if (onlyShowPayElsewhere && reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) {
    return isAdmin;
    }
    const isAutoReimbursement = reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES;
    const isManualReimbursement = reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL;
    // Reimbursement is disabled for this workspace.
    if (!isAutoReimbursement && !isManualReimbursement) {
    return false;
    }

    The pay side deliberately sets the flag to true through canIOUBePaid, which lets REIMBURSEMENT_NO admins 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 isPayer together with a WORKFLOWS_PAYMENTS write check, so any admin with payments write access can mark as paid even if they are not the designated reimburser:

    const isReportPayer = isPayerReportUtils(currentUserAccountID, currentUserLogin, iouReport, bankAccountList, policy, onlyShowPayElsewhere);
    const canPay =
    isReportPayer ||
    (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL && canMemberWrite(policy, currentUserLogin, CONST.POLICY.POLICY_FEATURE.WORKFLOWS_PAYMENTS));

    const isReportPayer = isPayer(currentUserAccountID, currentUserLogin, report, bankAccountList, policy, false);
    const canPayReport =
    isReportPayer ||
    (canNonPayerAdminPay &&
    policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL &&
    canMemberWrite(policy, currentUserLogin, CONST.POLICY.POLICY_FEATURE.WORKFLOWS_PAYMENTS));

    isCancelPaymentAction has no equivalent widening, so a non-reimburser admin who marked the report paid via the WORKFLOWS_PAYMENTS path is also blocked from cancelling.

    There is a second independent defect in scope item 2: cancelPayment hard-codes the reverted state to APPROVED/APPROVED:

    const approvalMode = policy?.approvalMode ?? CONST.POLICY.APPROVAL_MODE.BASIC;
    const stateNum: ValueOf<typeof CONST.REPORT.STATE_NUM> = CONST.REPORT.STATE_NUM.APPROVED;
    const statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.APPROVED;

    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. canMemberWrite is already imported in this file:

    const arePaymentsDisabled = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO;
    const isPayerResult =
        isPayerUtils(currentAccountID, currentUserEmail, report, bankAccountList, policy, arePaymentsDisabled) ||
        (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL &&
            canMemberWrite(policy, currentUserEmail, CONST.POLICY.POLICY_FEATURE.WORKFLOWS_PAYMENTS));

    Passing arePaymentsDisabled rather than a blanket true is intentional: it unlocks Path A while leaving the reimburser/bank-account branch of isPayer intact for the NACHA-cutoff bank-cancel path. The WORKFLOWS_PAYMENTS OR 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 in getExpenseReportStateAndStatus:

    App/src/libs/ReportUtils.ts

    Lines 7017 to 7033 in 5d21950

    }
    const isInstantSubmitEnabledLocal = isInstantSubmitEnabled(policy);
    const isSubmitAndCloseLocal = isSubmitAndClose(policy);
    const arePaymentsDisabled = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO;
    if (isInstantSubmitEnabledLocal && arePaymentsDisabled && isSubmitAndCloseLocal && !isEmptyOptimisticReport) {
    return {
    stateNum: CONST.REPORT.STATE_NUM.APPROVED,
    statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
    };
    }
    if (isInstantSubmitEnabledLocal && !(isSubmitAndCloseLocal && isEmptyOptimisticReport)) {
    return {
    stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
    statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
    };

    const isOptionalApproval = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL;
    const revertsToOutstanding = isOptionalApproval && isInstantSubmitEnabled(policy) && arePaymentsEnabled(policy);
    
    const stateNum = revertsToOutstanding ? CONST.REPORT.STATE_NUM.SUBMITTED : CONST.REPORT.STATE_NUM.APPROVED;
    const statusNum = revertsToOutstanding
        ? CONST.REPORT.STATUS_NUM.SUBMITTED
        : (isOptionalApproval ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.APPROVED);

    Add isInstantSubmitEnabled and arePaymentsEnabled to the existing @libs/PolicyUtils import. predictedNextStatus derives from statusNum, 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.

  11. github-actions commented on Jul 31, 2026

    @github-actions
    Contributor

    ⚠️ @trasnake87 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  12. 92 remaining items

  13. melvin-bot commented on Sep 8, 2026

    @melvin-bot
    Author

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  14. melvin-bot commented on Sep 8, 2026

    @melvin-bot
    Author

    Payment Summary

    Resolving PRs:

    Upwork Job

    • Reviewer: @shubham1206agra owed $250 via NewDot
    • Assignee: @dilshodmackbook-sketch requires payment (Needs manual offer from BZ)

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  15. mallenexpensify commented on Sep 10, 2026

    @mallenexpensify
    Contributor

    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

  16. David-2002065 commented on Sep 10, 2026

    @David-2002065
    Contributor

    @mallenexpensify accepted thanks.

  17. mallenexpensify commented on Sep 12, 2026

    @mallenexpensify
    Contributor

    @dilshodmackbook-sketch paid, summary updated above. Thx.

  18. added
    ReviewingHas a PR in review
    and removed
    ReviewingHas a PR in review
    on Sep 22, 2026
  19. changed the title [-][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[/+] on Sep 24, 2026
  20. melvin-bot commented on Sep 24, 2026

    @melvin-bot
    Author

    @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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions