Skip to content

[Due for payment 2026-03-30] [$250] Expense - When workflows are disabled, deleting receipt shows unexpected error. #81493

Closed

Description

@jponikarchuk

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: V9.3.11-52
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-3777/folder/13176741/41237124/1155363689
Email or phone of affected tester (no customers): dreamnitethedragon+yydyd373@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Redminote 10S Android 13
App Component: Money Requests

Action Performed:

  1. Launch app
  2. Go to workspace settings - more features
  3. Disable workflows
  4. Go to LHN
  5. Open workspace chat
  6. Create a manual expense with a camera image entering merchant
  7. Open the expense
  8. Tap receipt - 3 dots - delete receipt

Expected Result:

When workflows are disabled, deleting receipt must not show unexpected error.

Actual Result:

When workflows are disabled, deleting receipt shows unexpected error.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022029613801691232332
  • Upwork Job ID: 2029613801691232332
  • Last Price Increase: 2026-03-05

Activity

  1. imadirtydog commented on Feb 5, 2026

    @imadirtydog

    Proposal

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

    When workflows are disabled, deleting receipt shows unexpected error.

    What is the root cause of that problem?

    The issue is that we allow removing a receipt from the report that is in status/state 2/2 and this seems to not be aligned with what BE expects. I assume that the backend is correct and not the front end, otherwise, the issue will have to be solved on the BE.

    Basically, the issue is that

    const canDeleteReceipt = canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT, true);
    returns true

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

    I think solution should be made on the level of this component

    const shouldShowDeleteReceiptButton = canDeleteReceipt && !readonly && !isDraftTransaction && !transaction?.receipt?.isTestDriveReceipt;

    Because, I don't see a way to properly isolate this case on level of canEditFieldOfMoneyRequest. For example, if we target only fieldToEdit === CONST.EDIT_REQUEST_FIELD.RECEIPT, then you could forbid some other functionality related to receipts that you did not want to target.

    The change to be made:

        const shouldShowDeleteReceiptButton = canDeleteReceipt && !readonly && !isDraftTransaction && !transaction?.receipt?.isTestDriveReceipt && !isClosedReport(transactionReport);
    

    What alternative solutions did you explore? (Optional)

    N/A

    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.

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 5, 2026
  3. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    Triggered auto assignment to @CortneyOfstad (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  4. MelvinBot commented on Mar 5, 2026

    @MelvinBot
    Contributor

    🔍 Issue Analysis

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

    When workflows are disabled on a workspace, deleting a receipt from an expense shows an "Unexpected error deleting this receipt" message. The delete button should either not appear, or the deletion should succeed.

    What is the root cause of that problem?

    When workflows are disabled, the policy's approvalMode is set to OPTIONAL (Submit & Close) and reimbursementChoice to REIMBURSEMENT_NO. Under these conditions, expense reports transition to CLOSED state (stateNum=2/APPROVED, statusNum=2/CLOSED) — either optimistically at creation time (via getExpenseReportStateAndStatus) or when the backend auto-processes them.

    The frontend allows receipt deletion on CLOSED reports because of a gap in permission checks for admin/manager users:

    1. canEditMoneyRequest returns true unconditionally for admin/manager users, bypassing the isClosedReport check that exists at line 4706 for regular requestors.

    2. The restricted-field guard in canEditFieldOfMoneyRequest checks isSettled (statusNum=REIMBURSED/4) and isReportIDApproved (statusNum=APPROVED/3), but does not check isClosedReport (statusNum=CLOSED/2). Since CLOSED has a different statusNum than REIMBURSED or APPROVED, neither guard catches it.

    3. The RECEIPT-specific check has no closed-report guard either.

    So the delete button is shown, the user taps it, detachReceipt fires the DETACH_RECEIPT API call with no additional validation, the backend rejects it (because the report is CLOSED), and the failureData surfaces the "Unexpected error deleting this receipt" message.

    Note: For non-admin requestors, the existing isClosedReport check at line 4706 already correctly blocks the delete button. The bug only manifests for users who are both an admin/manager AND the requestor.

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

    Add isClosedReport(moneyRequestReport) to the restricted-field guard at App/src/libs/ReportUtils.ts:4821:

    Current:

    if (isSettled(String(moneyRequestReport.reportID)) || isReportIDApproved(String(moneyRequestReport.reportID))) {
    

    Proposed:

    if (isSettled(String(moneyRequestReport.reportID)) || isReportIDApproved(String(moneyRequestReport.reportID)) || isClosedReport(moneyRequestReport)) {
    

    This is consistent with how isSettled and isReportIDApproved already work — all three represent terminal report states where restricted fields (including RECEIPT) should not be editable. The isClosedReport function is already defined and used elsewhere in the same file.

    What alternative solutions did you explore? (Optional)

    The existing proposal from imadirtydog suggests adding !isClosedReport(transactionReport) to shouldShowDeleteReceiptButton in TransactionReceiptModalContent.tsx. While that would fix the delete button visibility in that specific component, fixing it at the canEditFieldOfMoneyRequest level in ReportUtils.ts is more robust because:

    1. It fixes the root cause rather than patching one UI consumer
    2. It protects ALL restricted fields (not just RECEIPT) from being editable on closed reports
    3. Any other code that calls canEditFieldOfMoneyRequest with RECEIPT also gets the fix automatically

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Mar 5, 2026
  6. 30 remaining items

  7. melvin-bot commented on Mar 30, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    • Reviewer: @truph01 owed $250 via NewDot

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2029613801691232332/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  8. melvin-bot commented on Mar 30, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    • Reviewer: @truph01 owed $250 via NewDot

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2029613801691232332/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  9. mallenexpensify commented on Mar 30, 2026

    @mallenexpensify
    Contributor

    @truph01 I'm planning to apply the 50% regression penalty here cuz of

    Comment with reasoning if you disagree.

    Also, plz complete the BZ checklist and tag me in a post once you have. Thx

  10. truph01 commented on Mar 31, 2026

    @truph01
    Contributor

    @mallenexpensify Based on #85669 (comment), #85669 isn't a regression from my PR.

  11. truph01 commented on Mar 31, 2026

    @truph01
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment:

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    Test:

    1. Log in as a workspace admin
    2. Go to workspace settings → More features → Disable workflows
    3. Go to LHN → Open workspace chat
    4. Create a manual expense with a camera image, entering a merchant name. Then submit it.
    5. Open the expense → Tap the receipt image → Tap the 3-dot menu
    6. Verify the "Delete receipt" option is not shown (previously it was shown and caused an unexpected error)

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-8a6c-acd5-3123-41dd5ebfab44
  12. truph01 commented on Mar 31, 2026

    @truph01
    Contributor

    @mallenexpensify I completed checklist

  13. mallenexpensify commented on Apr 1, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @truph01 due $250 via NewDot
    ^ Test case created. thx

  14. m-natarajan commented on Apr 1, 2026

    @m-natarajan

    @truph01 This is regarding the regression test proposal
    Delete receipt option is displayed, Is this flow changed or Am I missing anything here?

    Recording.2632.mp4
  15. truph01 commented on Apr 2, 2026

    @truph01
    Contributor

    Create a manual expense with a camera image, entering a merchant name

    @m-natarajan It should be:

    Create a manual expense with a camera image, entering a merchant name. Then submit it.

    I've updated regression test.

  16. garrettmknight commented on May 10, 2026

    @garrettmknight
    Contributor

    $250 approved for @truph01

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 productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded 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