Skip to content

Fix cancel payment showing after the NACHA cutoff has passed - #97556

Merged
iwiznia merged 31 commits into
Expensify:mainfrom
mukhrr:fix/96345
Sep 21, 2026
Merged

iwiznia merged 31 commits into
Expensify:mainfrom
mukhrr:fix/96345

Conversation

@mukhrr

@mukhrr mukhrr commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Canceling a bank payment showed "Auth CancelReimbursement returned an error" because the app inferred cancellability from report state (APPROVED/BILLING/AUTOREIMBURSED + REIMBURSED) plus a NACHA cutoff heuristic. The backend's canCancel actually gates on the credit not having posted yet (state BILLING + status REIMBURSED exactly), and some payment types (fast ACH, Stripe Connect, booked Corpay) post the credit immediately, so they are never cancellable and no client-side inference can know that. Details in #97556 (comment).

Per that suggestion, the app now asks the backend directly: a new side effect command GetReportCancelReimbursementStatus is called when a reimbursed expense report is opened, the result is stored in Onyx (reportCancelReimbursementStatus_<reportID>), and Cancel payment is only offered when canCancel is true. The state inference and the NACHA cutoff check are removed.

Unchanged: paid elsewhere cancellation, and the guard that hides the option while the report's pay actions haven't loaded (we can't tell a bank payment from an elsewhere payment yet).

Fixed Issues

$ #96345
PROPOSAL: #96345 (comment)

Tests

  1. As a workspace admin with a verified business bank account, approve an employee's expense report and pay it with the bank account.
  2. Open the paid report and press More: Cancel payment is not offered, because the backend reports the reimbursement as not cancellable. Previously it was offered and clicking it showed "Auth CancelReimbursement returned an error". Note for testing with a test bank account: Auth skips the reimbursements row for those, so canCancel is always false and the option stays hidden for every bank payment, see Fix cancel payment showing after the NACHA cutoff has passed #97556 (comment).
  3. Approve another report, then Pay > Mark as paid, then More > Cancel payment: the option is offered and succeeds, and the report returns to approved.
  • Verify that no errors appear in the JS console

Offline tests

  1. Pay a report with Mark as paid while online, then go offline. Cancel payment is still offered for the elsewhere payment and cancels optimistically, then syncs when back online.
  2. A bank-paid report opened while offline does not offer Cancel payment, since the app can't confirm cancellability it stays hidden rather than risking the error.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android_app.mp4
Android: mWeb Chrome
android_web.mp4
iOS: Native
ios_app.mp4
iOS: mWeb Safari
ios_web.mp4
MacOS: Chrome / Safari
MacOS: Desktop
96345-web.mp4

@mukhrr
mukhrr requested review from a team as code owners July 31, 2026 09:32
@melvin-bot
melvin-bot Bot requested review from dmkt9 and removed request for a team July 31, 2026 09:32
@melvin-bot

melvin-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

@dmkt9 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested review from flaviadefaria and removed request for a team July 31, 2026 09:32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0413680a64

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/libs/ReportSecondaryActionUtils.ts Outdated
Comment on lines +431 to +432
if (payActions.length === 0) {
return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep elsewhere cancellations available when actions are paged out

When a reimbursed report was paid elsewhere but its PAY action is not in the currently loaded report-actions page (for example, cold-opening a long report with many newer comments/system actions), getAllReportActions(report.reportID) can return no pay actions even though the payment is cancellable; the More menu subscribes via usePaginatedReportActions in src/components/MoneyReportHeaderActions/MoneyReportHeaderSecondaryActions.tsx:155-156 and does not force-load the older PAY action. This early return therefore hides Cancel payment until the user happens to load that old action, regressing the previous paid-elsewhere fallback where no NACHA cutoff check was needed.

Useful? React with 👍 / 👎.

@mukhrr

mukhrr commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@iwiznia while verifying the fix for this issue I hit the same error in a case the frontend can't detect.

Repro on staging: verified test business bank account (routing 011401533), approved report, paid with the bank account, then Cancel payment about 10 minutes later. It was 10:54 UTC, far before the 23:45 UTC cutoff, and the backend still returned "Auth CancelReimbursement returned an error". At that point the report was APPROVED/REIMBURSED with the pay action loaded (paymentType ACH), so the app showed the option exactly per the cutoff rules from #69731.

Can you confirm the backend behavior: does CancelReimbursement cancel a queued ACH withdrawal before the daily batch on production, or is an ACH payment uncancellable as soon as it's made?

If it's uncancellable, the right fix is to stop offering Cancel payment for bank payments entirely and I'll update my PR that way. The current PR (#97556) fixes the cases where the option was shown after the cutoff had passed and while report actions were still loading, which cover the repro in the OP.

I kinda feel this is BE issue. cc @dmkt9

@mukhrr

mukhrr commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Or else I found better RCA and solution (I guess):

Root cause

isCancelPaymentAction() offers Cancel payment for any bank-paid report based on report state alone (APPROVED/BILLING/AUTOREIMBURSED + REIMBURSED) plus a NACHA cutoff check. But the backend can only cancel a reimbursement while it's still queued, which is only the case while the payee has no bank account in their wallet. Once the payee has one, the withdrawal starts immediately and CancelReimbursement fails — the OP's precondition includes the payee having a personal bank account. Verified on staging: paid via ACH, canceled 10 minutes later (13h before the 23:45 UTC cutoff), still got the error.

Two more holes show the option when it can't work:

  • the cutoff check parses the pay action's created (a UTC db string with no timezone suffix) with new Date(), i.e. as local time, so devices behind UTC keep the option up to a full day after the batch has left
  • an empty pay-action list (report actions still loading) is treated as "paid elsewhere" and shows the option with no checks at all

Solution

Gate the bank branch on an active queued reimbursement (helpers already exist in ReportActionsUtils), parse the timestamp as UTC, and don't guess while pay actions aren't loaded:

+ const queuedReimbursementCount = allActionsArray.filter((action) => !!action && isReimbursementQueuedAction(action)).length;
+ const dequeuedReimbursementCount = allActionsArray.filter((action) => !!action && isReimbursementDeQueuedOrCanceledAction(action)).length;
+ const hasActiveQueuedReimbursement = queuedReimbursementCount > dequeuedReimbursementCount;
- const isBankProcessing = isPaidViaBankAccount && (isInBillingState || isApprovedAndReimbursed || isAutoReimbursed);
+ const isBankProcessing = isPaidViaBankAccount && hasActiveQueuedReimbursement && (isInBillingState || isApprovedAndReimbursed || isAutoReimbursed);
- const paymentDatetime = new Date(action.created);
+ const paymentDatetime = fromZonedTime(action.created, 'UTC');
+ if (payActions.length === 0) {
+     return false;
+ }

@dmkt9 what do you think?

@iwiznia could you pls confirm this ?

isCancelPaymentAction() offers Cancel payment for any bank-paid report based on report state alone (APPROVED/BILLING/AUTOREIMBURSED + REIMBURSED) plus a NACHA cutoff check. But the backend can only cancel a reimbursement while it's still queued, which is only the case while the payee has no bank account in their wallet.

@mukhrr
mukhrr marked this pull request as draft July 31, 2026 12:12
@iwiznia

iwiznia commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

The frontend gap is real, but the cause isn't the payee's wallet. canCancel gates on creditPosted IS NULL, not STATE_QUEUED, regular ACH stays cancellable until the debit posts, payee bank account or not. cancelBatchReimbursements1 asserts canCancel == true for a row already past queued.

What can't be cancelled is payment type: fast ACH (credit posts immediately, L585), Stripe Connect (L486), booked Corpay. Your repro looks like fast ACH, what was the exact error string? What is the requestID?

Separately, canCancel requires state BILLING + status REIMBURSED exactly, so accepting APPROVED/AUTOREIMBURSED is a second mismatch (AUTOREIMBURSED is post-batch, cancel already gone). Fix either way: call GetReportCancelReimbursementStatus instead of inferring from state.

@mukhrr

mukhrr commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor Author

@iwiznia thanks for clarification.

Your repro looks like fast ACH

How much "fast" means at maximum? 1 minute? 1 hour? I tried after 30minues as well

what was the exact error string?

"Auth CancelReimbursement returned an error"

Payload

curl 'https://dev.new.expensify.com:8082/staging/api/CancelPayment?'
-H 'accept: /'
-H 'accept-language: en-US,en;q=0.9,uz;q=0.8'
-H 'baggage: sentry-environment=staging,sentry-release=new.expensify%409.4.47-0,sentry-public_key=7b463fb4d4402d342d1166d929a62f4e,sentry-trace_id=e25fae765b0f4a89b024c46d069ccd0a,sentry-org_id=4510228013121536,sentry-transaction=Route%20Change,sentry-sampled=true,sentry-sample_rand=0.7450493266952433,sentry-sample_rate=1'
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundaryaB2xB5TrmSTclsXi'
-H 'origin: https://dev.new.expensify.com:8082'
-H 'priority: u=1, i'
-H 'referer: https://dev.new.expensify.com:8082/search/r/1534790247507182?backTo=%2Fsearch%3Fq%3Dtype%253Aexpense-report%2520sortBy%253Adate%2520sortOrder%253Adesc'
-H 'sec-ch-ua: "Not;A=Brand";v="8", "Chromium";v="150", "Google Chrome";v="150"'
-H 'sec-ch-ua-mobile: ?0'
-H 'sec-ch-ua-platform: "macOS"'
-H 'sec-fetch-dest: empty'
-H 'sec-fetch-mode: cors'
-H 'sec-fetch-site: same-origin'
-H 'sentry-trace: e25fae765b0f4a89b024c46d069ccd0a-9324f638d6173cb0-1'
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36'
--data-raw $'------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="iouReportID"\r\n\r\n1534790247507182\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="chatReportID"\r\n\r\n1656853160706542\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="managerAccountID"\r\n\r\n22532870\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="reportActionID"\r\n\r\n9012988934894641253\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="apiRequestType"\r\n\r\nwrite\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="pusherSocketID"\r\n\r\n900061.2292084\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="shouldRetry"\r\n\r\ntrue\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="canCancel"\r\n\r\ntrue\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="referer"\r\n\r\necash\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="platform"\r\n\r\nweb\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="api_setCookie"\r\n\r\nfalse\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="email"\r\n\r\nmshakhriyorov8+00@gmail.com\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="isFromDevEnv"\r\n\r\nfalse\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="appversion"\r\n\r\n9.4.47-0\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="authToken"\r\n\r\n9D223C30165DD238832A0D503828D559F36C902AB1231B762074A0C60E12CBBEB3F5D1C96C6EF50037B42566F1CCE9635AFEDC22BE3A6843B6F4BAF9968C6C776FBB1FD857D4F06AB554A35B258FAD442FFE71EB528F5595AB9A161825BB38EF31F4399170F8A4ED4DCE4ADAF3D5F4B5F90DE509515487F9321398BE493F3704CEC249C5C6B9343F000A6214CCB239010D9786B8864E87E18CA4DF879EBF8BE782B08892DDE6F076786485CA78880FAB7C4C2FFBEA8B702812A2428C2671A0DB283C1BB0EBFED1330371B34962B369547B3A3A177DCC44D9C884371233B123672BF059C5DEAA21A14E5433B5BA67B50C99DE66294FF4115349325180A4BAA5F08696E380B273C11846C7E43CA34E4CF52AEE00E8EBF49109D479081C0404CC1CFE767C7B54B5FD10D19503B728926FFC0C0EC032AD28706B75CB612E573C3F11FFD9EEE9BB40A0A136F387CD572B7FD2133D1849F9FD113DFD16396B22FD08B256ADFC9CC3AAF4B51546D7E4F2AE8F5D8C2903AFD79765AC2F07379E61800708\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi\r\nContent-Disposition: form-data; name="clientUpdateID"\r\n\r\n14999413498\r\n------WebKitFormBoundaryaB2xB5TrmSTclsXi--\r\n'

Response:

{
    "code": 666,
    "jsonCode": 666,
    "type": "Expensify\\Libs\\Error\\ExpError",
    "UUID": "A4B9B751-6E44-4AC8-9F80-0CB4C4A6B659",
    "message": "Auth CancelReimbursement returned an error",
    "title": "",
    "data": {
        "onyxData": [
            {
                "onyxMethod": "merge",
                "key": "reportActions_1534790247507182",
                "value": {
                    "9012988934894641253": {
                        "errors": {
                            "1785586189587213": "Auth CancelReimbursement returned an error"
                        }
                    }
                }
            }
        ]
    },
    "htmlMessage": "",
    "onyxData": [
        {
            "onyxMethod": "merge",
            "key": "reportActions_1534790247507182",
            "value": {
                "9012988934894641253": {
                    "errors": {
                        "1785586189587213": "Auth CancelReimbursement returned an error"
                    }
                }
            }
        }
    ],
    "requestID": "a244bc743c23b905-SJC"
}

P.s: I tried to cancel right after paying, i.e, in 10 seconds

@mukhrr

mukhrr commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

@iwiznia PR updated per your suggestion: the app now calls GetReportCancelReimbursementStatus when a reimbursed report is opened and only shows Cancel payment when canCancel is true. State inference and the NACHA cutoff check are gone.

And is there a way to get a regular (cancellable) ACH on staging for QA, or should QA steps cover the elsewhere flow only?

@codecov

codecov Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/libs/DebugUtils.ts 69.12% <100.00%> (+0.03%) ⬆️
src/libs/ReportSecondaryActionUtils.ts 96.30% <100.00%> (-0.10%) ⬇️
src/libs/actions/IOU/PayMoneyRequest.ts 81.46% <ø> (ø)
src/selectors/Report.ts 85.15% <ø> (+1.39%) ⬆️
src/types/utils/whitelistedReportKeys.ts 100.00% <ø> (ø)
... and 1048 files with indirect coverage changes

@mukhrr
mukhrr marked this pull request as ready for review August 2, 2026 12:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 641f682535

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/libs/ReportSecondaryActionUtils.ts Outdated
const isBankPaymentCancellable = !!reimbursementCancellableStatus?.canCancel;

return isPaymentProcessing && !hasDailyNachaCutoffPassed;
return (!!report.isWaitingOnBankAccount && report.statusNum === CONST.REPORT.STATUS_NUM.APPROVED) || (isPaidViaBankAccount && isBankPaymentCancellable);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate bank cancellation on a reimbursed report state

When a bank reimbursement is reported as cancellable and then the user cancels it, cancelPayment() moves the report back to APPROVED but does not clear reportCancelReimbursementStatus_<reportID>, and this hook also stops refreshing once the report is no longer REIMBURSED. Because this branch only checks the historical PAY action plus the stale canCancel, the More menu can continue to show Cancel payment on the already-canceled/approved report, leading to another CancelPayment attempt for a payment that no longer exists; keep the backend flag scoped to the reimbursed/billing states or clear it when cancellation succeeds.

Useful? React with 👍 / 👎.

Comment thread src/types/onyx/Response.ts Outdated
statementKey?: string;

/** Whether a report's bank reimbursement can still be canceled, from GetReportCancelReimbursementStatus */
reimbursementCancellableStatus?: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-3 (docs)

The inline reimbursementCancellableStatus object type added here duplicates the exact shape (canCancel?: boolean and isWaitingForCreditToPost?: boolean, including the doc comments) of the new ReportCancelReimbursementStatus type added in src/types/onyx/ReportCancelReimbursementStatus.ts. Two identical definitions can drift apart over time. Response.ts already references named types elsewhere (e.g. transactionsPending3DSReview?: TransactionsPending3DSReview), so reuse the named type here instead of redefining its shape inline:

import type ReportCancelReimbursementStatus from './ReportCancelReimbursementStatus';

// ...

    /** Whether a report's bank reimbursement can still be canceled, from GetReportCancelReimbursementStatus */
    reimbursementCancellableStatus?: ReportCancelReimbursementStatus;

Reviewed at: 641f682 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

@iwiznia

iwiznia commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

How much "fast" means at maximum? 1 minute? 1 hour? I tried after 30minues as well

between 24 hours and 2-3 business days

Response:

Thanks! Logs are not that useful as they are not printing the exact reason of the failure...

I see this in the DB:

       created: 2026-08-01 12:09:26.977
      reportID: 1534790247507182
     accountID: 22532870
        action: REIMBURSED
       message: {"accountNumber":"111122XXXXXX1111","addressName":"Alberta Bobbeth Charleson","creditBankAccountNumber":"0000","expectedDate":"2026-08-04","isNewDot":true,"method":"Fast_ACH","routingNumber":"011401533"}
reportActionID: 2814784485923373926

ionatan@db2.rno:~$ r -line "select * from reimbursements where reportID = 1534790247507182"

ionatan@db2.rno:~$

So no reimbursement entry, I think due to it being the test bank account? Asking here

@iwiznia

iwiznia commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@mukhrr

mukhrr commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor Author

ok thanks. @iwiznia so I think we can rely on canCancel from GetReportCancelReimbursementStatus?! If so, PR is ready to review. cc @dmkt9

I think due to it being the test bank account?

Yes, I tried with test BA

@dmkt9

dmkt9 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@mukhrr We have conflicts

Comment thread src/types/onyx/Report.ts
errors?: OnyxCommon.Errors;

isWaitingOnBankAccount?: boolean;
canCancelReimbursement?: boolean;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment for this

Comment thread src/libs/ReportSecondaryActionUtils.ts Outdated
const isReimbursementSubmitted = report.stateNum === CONST.REPORT.STATE_NUM.BILLING && report.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED;

return isPaymentProcessing && !hasDailyNachaCutoffPassed;
return isPaidViaBankAccount && isReimbursementSubmitted && !hasCutoffPassed && !!report.canCancelReimbursement;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to clear report.canCancelReimbursement optimistically once the cancellation is requested. Otherwise, report.canCancelReimbursement could become stale.

@dmkt9

dmkt9 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@iwiznia The PayMoneyRequest API doesn't currently return canCancelReimbursement. I wonder if reopening the report just to get this value might be a bit inconvenient.

@dmkt9

dmkt9 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1a462df28

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/libs/ReportSecondaryActionUtils.ts Outdated
const isReimbursementSubmitted = report.stateNum === CONST.REPORT.STATE_NUM.BILLING && report.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED;

return isPaymentProcessing && !hasDailyNachaCutoffPassed;
return isPaidViaBankAccount && isReimbursementSubmitted && !hasCutoffPassed && !!report.canCancelReimbursement;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refresh cancellability before offering cancellation

When OpenReport returns canCancelReimbursement: true and the report remains mounted while the credit posts or the cutoff passes, this condition continues trusting the persisted snapshot; reading new Date() here does not itself trigger a React render, and no remaining hook or timer refreshes the backend flag. The More menu can therefore retain Cancel payment and send a request Auth now rejects. Fresh evidence in this revision is that the prior refresh hook has been replaced by this report field, whose only client-side mutation is during a cancellation attempt; refresh or invalidate it when opening the menu or on an appropriate lifecycle event.

Useful? React with 👍 / 👎.

@mukhrr mukhrr Sep 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm cutoff part is not new, main has the same new Date() here. the flag doesnt need a refresh (I hope). @iwiznia when credit posts Auth moves the report out of BILLING, that comes through Pusher?? or am I wrong? here refresh on menu open means extra API call, the 1:1:1 thing we dropped intentionally

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it comes through pusher but I also don't think it's a problem. Yes in the very unlikely case you had the report open, the reimbursement cancelation changes and you try to cancel the reimbursement, you'll get an error. That's so unlikely that I don't think we care.

@iwiznia

iwiznia commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@iwiznia The PayMoneyRequest API doesn't currently return canCancelReimbursement. I wonder if reopening the report just to get this value might be a bit inconvenient.

hmmm yeah, sent a PR to return it there too.

value: {
statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED,
isWaitingOnBankAccount: expenseReport.isWaitingOnBankAccount,
canCancelReimbursement: expenseReport.canCancelReimbursement,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized there's one case where, if cancelPayment fails because the NACHA cutoff has already passed, canCancelReimbursement gets restored to true, causing the Cancel Payment option to appear again. However, as @iwiznia mentioned, this case is pretty rare, so I think we can ignore it for now.

@dmkt9

dmkt9 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
chrome.mp4

@dmkt9 dmkt9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@melvin-bot
melvin-bot Bot requested a review from iwiznia September 16, 2026 02:41
@mukhrr

mukhrr commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

@iwiznia kindly bump

Comment thread src/libs/ReportSecondaryActionUtils.ts Outdated
const isAutoReimbursed = report.stateNum === CONST.REPORT.STATE_NUM.AUTOREIMBURSED && report.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED;
const isBankProcessing = isPaidViaBankAccount && (isInBillingState || isApprovedAndReimbursed || isAutoReimbursed);
const isPaymentProcessing = (!!report.isWaitingOnBankAccount && report.statusNum === CONST.REPORT.STATUS_NUM.APPROVED) || isBankProcessing;
const hasCutoffPassed = hasPayActionPassedNachaCutoff(latestPayAction);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm not sure I get this, why are we not just relying on the value of canCancelReimbursement (same below)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice catch. yeah, it makes sense 👍 we can rely on BE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iwiznia I think we still need hasCutoffPassed here in case canCancelReimbursement becomes stale while offline. Otherwise, we should disable Cancel Payment entirely when we're offline.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmkt9 I think the cutoff doesn't match what Auth checks. I am thinking maybe we should gate cancelling with offline? @iwiznia what are your thoughts on this?

@mukhrr
mukhrr requested a review from iwiznia September 19, 2026 08:09
@iwiznia
iwiznia merged commit d335dd4 into Expensify:main Sep 21, 2026
35 of 37 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 iwiznia has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/iwiznia in version: 9.4.91-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

Yes, help site changes were required. Draft PR: Docs updates for E/A#97556 Clarify when Cancel payment is available

Why: this PR replaced the client-side cancellability guess (report state + NACHA cutoff) with the backend's answer, so Cancel payment now only appears when the reimbursement can actually still be stopped — and never for payment types that post the credit immediately. Two articles described the old model, and one of them contradicted itself.

What changed in the docs

  • docs/articles/new-expensify/reports-and-expenses/Expense-and-Report-Actions.md
    • Added Cancel payment to the actions listed for Paid or Done reports.
    • Replaced "before processing" in the Payer role list and in both Cancel payment table rows with the real rule: always on a manual payment, and on a bank payment only while Expensify can still stop the transfer.
    • Rewrote the "Why can’t I cancel a payment?" FAQ. It said "Manual payments cannot be canceled", which is wrong — that path is unchanged by this PR and still always cancellable — and it contradicted the table in the same article.
  • docs/articles/new-expensify/wallet-and-payments/Pay-Expenses.md
    • Added an FAQ for why Cancel payment is missing on a report paid with a business bank account. The article only documented cancelling a personal Wallet payment, so payers had no answer.

No Expensify Classic change needed — Cancel ACH Reimbursement already describes cancellation as available only before the funds are withdrawn, which is the model New Expensify now matches.

Verification and conventions
  • UI labels verified against the live web app on a paid report: the report header button is More, the menu option is Cancel payment, and the confirmation reads "Are you sure that you want to cancel this payment?" with a Cancel payment confirm button and a Dismiss button. Cross-checked against src/languages/en.ts lines 283 and 1450–1451.
  • Written against docs/HELPSITE_NAMING_CONVENTIONS.md, docs/HELP_AUTHORING_GUIDELINES.md, and docs/TEMPLATE.md: UI labels bolded in Sentence case with no quotation marks, FAQ headings kept in question form, no new # or ### headings, and no restructuring of the existing articles beyond the affected content.
  • The HelpDot label is applied and the PR is a draft. GitHub rejected both the assignment and a review request for mukhrr ("not a collaborator of the Expensify/App repository"), so the docs PR tags them in the body instead.

@mukhrr, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.91-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants