Skip to content

[Due for payment 2026-10-07] [Exploratory] Expense - Unable to move undeleted expense to workspace. #97677

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.4.48-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/test-runs/67224479/folder/52649115/104398848/1622118101?q=Undelete&issue_type=jira
Email or phone of affected tester (no customers): ibellicotest+2766@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome
App Component: Money Requests

Action Performed:

Prerequisite: Account has Self DM.
Prerequisite 2: Account has a workspace.

  1. Open the staging.new.expensify.com website.
  2. Create a manual expense and submit it to Self DM.
  3. Navigate to "Spend" > "Expenses"
  4. Select and delete the just created expense.
  5. Click on "FIlters" > "Status" > "Deleted"
  6. Select the just deleted expense.
  7. Click on dropdown menu > "Undelete"
  8. Return to Self DM.
  9. Open the expense.
  10. Click on report field > "Create Report"
  11. Note that a "It´s not here" message appears on RHP after expense is moved.
  12. Navigate to workspace chat and reopen expense.
  13. Note that infinite loading is displayed.
  14. Right click on expense preview and delete it.
  15. Note that expense returns to Self DM.

Expected Result:

User should be able to move and undeleted expense to a new report in workspace chat.

Actual Result:

User is unable to move an undeleted expense to a new report in workspace chat. "It´s not here" is displayed on RHP after expense is moved and infinite loading experienced when reopening expense in workspace chat.
After deleting expense from workspace chat, it returns to Self DM.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7224028_1785686196854.Move_Undelete.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Nathan Lemma
Bug ID: 7224028

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. applause-bot commented on Aug 3, 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/73106e210225f85f71fffb6f7f72151769ac1941f16fa042ce0e7746a9f90a66

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 5, 2026
  3. MelvinBot commented on Sep 5, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    Deleting a Self DM expense leaves a stale IOU report action in the Self DM that still points at the transaction. After Undelete, the Self DM contains two actions for the same transactionID, and "Create Report" picks the stale (deleted) one — which carries a childReportID for a transaction thread that no longer exists.

    The chain:

    1. Delete a self-DM tracked expense calls getDeleteTrackExpenseInformation with shouldRemoveIOUTransaction: false (src/libs/actions/IOU/TrackExpense.ts:3057). The original IOU action is blanked (html: '', pendingAction: DELETE) but keeps originalMessage.IOUTransactionID (TrackExpense.ts:697-716). Its transaction thread is removed.
    2. Undelete is not a real undo — it calls changeTransactionsReport with no destination, i.e. "move to Unreported" (src/hooks/useUndeleteTransactions.ts:31-51). Because the transaction is still in Trash, the old-action lookup is deliberately skipped (src/libs/actions/Transaction.ts:1098-1104), so a brand new IOU action and thread are created — leaving the blanked one in place. The Self DM now has two actions matching this transactionID.
    3. Create Report calls changeTransactionsReport again. The transaction is no longer in Trash, so the lookup runs — and getIOUActionForTransactionID is an unfiltered .find() with no deleted/pending check, so it can return the stale action (src/libs/ReportActionsUtils.ts:2689-2706).
    4. newIOUAction is built as {...oldIOUAction} (Transaction.ts:1123-1138), inheriting the dangling childReportID and the blanked message. Because childReportID is truthy, the "create the thread if missing" branch is skipped (Transaction.ts:1594-1600), and the thread merge is also skipped because that report isn't in Onyx (Transaction.ts:1565-1580).

    So the moved expense points at a transaction thread that exists nowhere: the RHP resolves no report and renders the not-found page (src/pages/inbox/ReportNotFoundGuard.tsx:56-73), and the workspace-chat preview never gets data to render. The expense reappearing in the Self DM after deletion is the backend state showing through once the optimistic overlay is gone — the move was never committed with a valid thread.

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

    1. Never resolve a deleted action as the "old" IOU action. At Transaction.ts:1104, skip actions that are deleted (isDeletedAction) or have pendingAction === DELETE, and prefer the most recently created match. Doing it at this call site rather than inside getIOUActionForTransactionID avoids touching its ~15 other callers.
    2. Don't trust a dangling childReportID. In the same function, treat newIOUAction.childReportID as absent when no report exists for it in Onyx, so a fresh transaction thread is built (Transaction.ts:1594-1600). This also protects every other move path from a stale thread ID.
    3. Clean up on undelete. Since Undelete already creates a replacement action, have it null out the blanked original's originalMessage.IOUTransactionID so only one action ever claims a transaction.

    Fixes 1 and 2 are independently sufficient for this repro; 3 stops the duplicate from existing at all.

    What alternative solutions did you explore?

    • Make delete remove the IOU action entirely (shouldRemoveIOUTransaction: true). Rejected — that flag exists so the Search "Deleted" filter and Undelete can still find the transaction.
    • Backend-only cause. The "expense returns to Self DM" symptom is consistent with ChangeTransactionsReport rejecting the move server-side. I could not verify the backend contract from this repo. If the client fixes above don't resolve it, an internal engineer should confirm the backend accepts a move for a just-undeleted transaction — that part is outside Expensify/App.
    Live repro attempt (did not reproduce on latest main) and confidence

    I ran the exact steps on web against main (0498f1e) and the move worked: the RHP rendered the moved expense and opening it from the workspace chat showed no infinite loading.

    After Undelete Undeleted expense back in a Self DM
    After "Create Report" Expense RHP after Create Report
    Opened from workspace chat Expense opened from workspace chat

    This is consistent with the root cause rather than contradicting it. In my run, Undelete surfaced a newly created Self DM report — changeTransactionsReport creates one when SELF_DM_REPORT_ID isn't set (Transaction.ts:941-1021) — so the restored expense landed in a Self DM that contained no stale action, and step 3 above found the correct action. That matches the issue's stated prerequisite ("Account has Self DM"): the bug needs the undeleted expense to return to the same Self DM that still holds the blanked action.

    The guard at Transaction.ts:1098-1104 was already present on 3 Aug 2026 (6a94d7f), and getIOUActionForTransactionID still has no deleted-action filter on main, so nothing has fixed this since the report.

    Confidence: Medium. Every step of the chain has file:line evidence, but I have no production log or live repro confirming which of the two actions .find() returns in the failing case. To confirm, capture the Self DM's reportActions after delete → undelete and check for two IOU actions with the same IOUTransactionID, then check whether the moved expense's childReportID matches the pre-delete thread ID.

    I did not find an existing open issue covering this.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/97677) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 5, 2026
  5. melvin-bot commented on Sep 5, 2026

    @melvin-bot

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

  6. melvin-bot commented on Sep 5, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. melvin-bot commented on Sep 9, 2026

    @melvin-bot

    @situchan Whoops! This issue is 2 days overdue. Let's get this updated quick!

  8. 62 remaining items

  9. melvin-bot commented on Oct 6, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    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
  10. mallenexpensify commented on Oct 9, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @samarroy84 paid $250 via Upwork
    Contributor+: @situchan due $250 via NewDot

    @samarroy84 can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022108386982186092795

  11. melvin-bot commented on Oct 15, 2026

    @melvin-bot

    @mallenexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

  12. mallenexpensify commented on Oct 16, 2026

    @mallenexpensify
    Contributor

    @samarroy84 paid, summary updated above. Thx.
    Plz comment and tag me once you accept so I can pay promptly

  13. trjExpensify commented on Nov 3, 2026

    @trjExpensify
    Contributor

    approved $250 for @situchan

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 contributorNot a priority

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions