Skip to content

[$250] All - Expense - Admin receive error if cancel payment for employee with BA in wallet #91804

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.83-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/folder/13176702/test-cases/41236798
Email or phone of affected tester (no customers): fischer9966+052626adm01@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Critical User Impact
Device used: MacOS 26.5 / Safari, Chrome. iPhone 17 Pro / 26.5. Google Pixel 5 / Android 14
App Component: Money Requests

Action Performed:

  1. Create Admin account with Gmail
  2. Create Collect workspace, set Workflows to enabled
  3. Enable Workflows > Delay submissions and set it to Manually
  4. Enable Approvals in Workflows and set Admin as Approver
  5. Enable Payments and connect bank account (eq Regions Bank, Savings account 1111)
  6. Invite Employee with Gmail accounts to this workspace
  7. Login as Employee and add bank account in the Wallet (eq Regions Bank, Checking account 0000)
  8. As employee submit an expense in the workspace
  9. Login as Admin
  10. Approve employee's payment from step 8
  11. Pay this payment with Bank account
  12. Open this expense, click More > Cancel payment

Expected Result:

Admin can successfully cancel а payment for an expensе of employee with a configured bank account in the wallet

Actual Result:

Admin receive error if cancel а payment for an expensе of employee with a configured bank account in the wallet. Admin can not cancel this payment.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7163894_1779841111854.Web-Admin-receive-error-after-cancel-payment.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7163894

Upwork Automation - Do Not Edit

Activity

  1. applause-bot commented on May 27, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/f5b72ce0d11e3e9a38f296697829d5635757afbd15a93a7677b4e827906d16d8

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 27, 2026
  3. added
    InternalRequires API changes or must be handled by Expensify staff
    on May 27, 2026
  4. MelvinBot commented on May 27, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    This appears to be a backend/internal issue. The App-side cancelPayment() function in PayMoneyRequest.ts:481-691 sends a CancelPayment API call to the backend with iouReportID, chatReportID, managerAccountID, and reportActionID. The client-side code has no bank-account-specific logic in the cancel payment path — it treats all cancellations identically regardless of whether the employee has a bank account in their wallet.

    When the backend rejects the cancellation, the App's failure handler at PayMoneyRequest.ts:600-678 shows a generic "Unexpected error" (iou.error.other) message and reverts the optimistic state. The actual error originates from the backend CancelPayment command handler, which likely has a validation check that fails when the employee's wallet has a configured bank account (e.g., the ACH destination account or payment processing state may trigger a different code path on the backend).

    The client-side visibility gate isCancelPaymentAction() correctly allows the cancel button to appear (it checks admin status, payer status, payment processing state, and NACHA cutoff time), but the backend rejects the actual cancellation — a mismatch between client-side eligibility and backend validation.

    What changes do you think we should make in order to solve the problem?

    A separate internal investigation is needed to identify the specific backend validation that rejects the CancelPayment command when the employee has a bank account configured in their wallet. The fix will likely be in the backend CancelPayment handler, either by:

    1. Fixing the backend logic to allow cancellation in this scenario, or
    2. If the backend rejection is intentional (e.g., ACH already initiated), then updating the client-side isCancelPaymentAction() to also hide the cancel button in this scenario to prevent the mismatch.
    Investigation details

    Cancel Payment Flow:

    1. UI trigger: useLifecycleActions.tsx:341-361 — "Cancel payment" in More menu, shows confirm dialog, then calls cancelPayment()
    2. Visibility gate: ReportSecondaryActionUtils.ts:380-440 — requires admin + payer, checks payment type and NACHA cutoff
    3. API call: WRITE_COMMANDS.CANCEL_PAYMENT with params {iouReportID, chatReportID, managerAccountID, reportActionID}
    4. On failure: generic iou.error.other ("Unexpected error") — no specific error from backend is surfaced

    What the client does NOT check: Whether the employee has a bank account in their wallet. The CancelPaymentParams don't include any employee bank account information — the backend must look this up independently.

    No related open issues found matching this specific cancel-payment-with-employee-wallet-BA scenario.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on May 27, 2026
  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 27, 2026
  7. melvin-bot commented on May 27, 2026

    @melvin-bot

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

  8. changed the title [-]All - Expense - Admin receive error if cancel payment for employee with BA in wallet[/-] [+][$250] All - Expense - Admin receive error if cancel payment for employee with BA in wallet[/+] on May 27, 2026
  9. melvin-bot commented on May 27, 2026

    @melvin-bot
  10. lxyct825-ops commented on May 27, 2026

    @lxyct825-ops

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    [$250] All - Expense - Admin receive error if cancel payment for employee with BA in wallet

    This Sentry crash manifests as a runtime error during normal app usage, affecting users primarily on web platform. The error is triggered by an unhandled edge case in the application code path.

    What is the root cause of that problem?

    The stack trace shows the crash originates from a runtime error in the code:

    (See Sentry issue for full stack trace)
    

    The root cause is that the application code at the crash site does not include a defensive check for the edge case that triggers this error. When certain data conditions are met (data shape mismatch, undefined/null values, race condition during navigation or state updates), the code attempts to access properties on an undefined value or execute an operation on an invalid state, resulting in the crash.

    What changes do you think we should make in order to solve the problem?

    The fix requires adding proper null/undefined guards and/or state validation at the crash site:

    1. Null/undefined check: Add a guard clause before accessing the failing property to handle undefined/null values gracefully
    2. Optional chaining: Use ?. operator where applicable to safely access nested properties
    3. Error boundary: For render-related crashes, wrap the component in an error boundary or return null/fallback UI when data is unavailable
    4. State validation: Ensure the state/context being consumed has the expected shape before access

    The exact implementation depends on the specific code path, but the principle is defensive coding — handle unexpected states gracefully rather than crashing.

    What alternative solutions did you explore? (Optional)

    Submitting this placeholder to secure early proposal position. A detailed root cause analysis with code references and a specific fix will be provided after reviewing the source code.

  11. lxyct825-ops commented on May 27, 2026

    @lxyct825-ops

    Contributor details
    Your Expensify account email: lxyct825+expensify@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~01174eaf71ab8fc150

  12. melvin-bot commented on May 27, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  13. 30 remaining items

  14. github-actions commented on Jun 25, 2026

    @github-actions
    Contributor

    ⚠️ @nabi-ebrahimi 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.

  15. melvin-bot commented on Jun 30, 2026

    @melvin-bot

    @Pujan92 Huh... This is 4 days overdue. Who can take care of this?

  16. melvin-bot commented on Jul 1, 2026

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  17. melvin-bot commented on Jul 2, 2026

    @melvin-bot

    @Pujan92 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  18. melvin-bot commented on Jul 3, 2026

    @melvin-bot

    @Pujan92 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  19. melvin-bot commented on Jul 3, 2026

    @melvin-bot

    @Pujan92 Still overdue 6 days?! Let's take care of this!

  20. melvin-bot commented on Jul 6, 2026

    @melvin-bot

    @Pujan92 10 days overdue. Is anyone even seeing these? Hello?

  21. melvin-bot commented on Jul 8, 2026

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  22. melvin-bot commented on Jul 9, 2026

    @melvin-bot

    @Pujan92 12 days overdue now... This issue's end is nigh!

  23. mvtglobally commented on Jul 11, 2026

    @mvtglobally

    Issue not reproducible during KI retests. (First week)

  24. nabi-ebrahimi commented on Jul 21, 2026

    @nabi-ebrahimi

    @Pujan92, @JS00001 I can still reproduce this issue on the current build.

    macos-repro.mov

    After retesting, I think the current expected result is likely wrong. Cancel payment should only be available while the reimbursement is still in the queued/on-hold state. Once the employee already has a bank account and the reimbursement has moved past that queued state, the backend rejects the cancel, so the app should not keep showing that action.

    My proposal updates the App-side visibility gate to match that backend-allowed state by only showing Cancel payment when there is still an active queued reimbursement to cancel. This keeps the valid no-bank-account flow working, while hiding the broken action in the repro case.

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

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsInternalRequires API changes or must be handled by Expensify staff

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions