You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix Expense - Unable to move undeleted expense to workspace - #102317
After delete → undelete, the self-DM has two IOU actions for the same transaction (the old blanked one plus the new live one). When the expense is moved, the lookup can pick the blanked one. The new action copies its blanked message, so the moved expense shows as deleted and the report loads forever. The live thread is never moved to the new report, so opening the expense shows "not here".
Fix: a new opt-in shouldPreferLiveAction flag on getIOUActionForReportID/getIOUActionForTransactionID returns the live action when both exist. In every other case it returns the same action as before. Only getChangeTransactionsReportOnyxData and useChangeTransactionsReportReports pass it. Added a regression test.
Prerequisite: Account has a Self DM and a workspace.
Create a manual expense in the Self DM.
Go to Spend > Expenses, select the expense and delete it.
Go to Filters > Status > Deleted, select the expense and choose Undelete from the dropdown.
Go back to the Self DM and open the expense.
Tap the Report field > Create report.
Verify the expense opens normally in the RHP ("Hmm… it's not here" isn't shown).
Go to the workspace chat and open the report.
Verify the report shows the expense, not an endless loading skeleton.
Verify that no errors appear in the JS console
Offline tests
Same as Tests
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 verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
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 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 any new file was added I verified that:
The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
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.
@situchan 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]
Verdict: Looks good. I found no blocking issues. The fix targets the cause in the move flow. The hook and the action now pick the same live IOU action, so the live transaction thread gets re-parented. The regression test covers both parts. All CI checks pass except Check independent approval, which is expected before a reviewer approves.
Non-blocking points to consider:
Other callers can still pick the blanked action. After an undelete, other flows use the default first match. Examples are useNavigateToTransactionThread.ts:59, hold/unhold in Hold.ts, and TransactionThreadNavigationUtils.ts:54. These could open the deleted thread for an undeleted self-DM expense. Keeping the flag opt-in is a safe choice for this PR. Still, please say in the PR whether you checked these flows, or file a follow-up.
The root cause is probably in the backend. Undelete leaves the old blanked action with its IOUTransactionID still set. The move flow itself clears it (IOUTransactionID: null) when it retires an action. Clearing it on undelete would remove the duplicate at the source. That change is outside App, so this frontend guard is a reasonable defense until then.
isLive depends on how isDeletedAction treats a missing message. In ReportActionsUtils.ts:2803, isDeletedAction treats a missing message as [], which counts as deleted. The !reportAction.message guard is correct and the comment explains it. A small unit test for getIOUActionForTransactionID alone would lock this in. Cover a single blanked match, blanked plus live in either order, and a pendingAction: delete match.
Nit: The open AI review comment about the semicolon in the JSDoc (CONSISTENCY-15) is still unresolved.
I did not run the test steps in the app. This review covers the code only.
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 that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
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 and each prop has a /** comment above it */
The file is named correctly
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
For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
All JSX used for rendering exists in the render method
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 any new file was added I verified that:
The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
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.
I found no regressions. Moving expenses between the Self DM and workspace reports worked in every case I tried: create report, remove from report, create report again, and delete then undelete. I also traced every caller of the move flow. The new flag changes the result only when the source report holds both a blanked action and a live action for the same expense, which is the bug case. The tool could not capture console logs, so step 8 relies on the absence of visible errors.
Step
Status
1. A never-deleted Self DM expense moved with Report > Create report opens normally in the RHPCreated a $25.00 "Melvin Test Merchant" expense in the Self DM, then used Report > Create report. The RHP showed "Expense Report 2026-09-25" with all expense fields and no "Hmm… it's not here" error.
✅
2. The new workspace report shows the expense with no endless loading skeletonThe new report showed the Merchant, Date, Category, Reimbursable, and Report fields right away, with no skeleton placeholders.
✅
3. Moving the expense back to the Self DM (Remove from report) works and the expense opens normallyThe workspace report showed "No expenses yet". The Self DM showed "tracking $25.00", and the expense opened with a "moved this expense to your personal space" line.
✅
4. Moving the same expense to a workspace report again worksReport > Create report made a new report. The RHP opened with all expense fields and no skeleton or error.
✅
5. A second expense is deleted in Spend > Expenses, then undeleted from the Deleted filterCreated a $40.00 "Melvin Delete Test" expense and deleted it. After Undelete, the Deleted filter showed "Nothing to show", which confirms the expense was restored.
✅
6. The undeleted expense moved with Report > Create report opens normally in the RHPThe undeleted expense opened normally in the Self DM. Report > Create report opened it in a new report with no "Hmm… it's not here" error.
✅
7. The workspace report from step 6 shows the expense with no endless loading skeletonThe report showed "Melvin Delete Test" with the Date, Category, Reimbursable, and Report fields right away and no skeleton loaders.
✅
8. No JS console errors about report actions or transactionsThe web test tool cannot read console logs, so console errors were not captured. No error banners, "not here" screens, or stuck skeletons appeared during any step.
No help site changes are needed for this PR, so I did not create a docs PR.
This PR fixes a bug in the code that picks which expense entry to move. The bug happened when you moved an undeleted expense to a report. It does not change any feature, setting, button, label, or step that a user sees. The expense now works the way the help site already says it should.
Why no docs update
Changed files:ReportActionsUtils.ts, Transaction.ts, useChangeTransactionsReportReports.ts, and a test. All of them are internal logic. There is no copy change and no change to src/languages.
Existing coverage:How-to-Delete-Expenses.md:77-86 already explains how to undelete an expense (Spend > Expenses > Status = Deleted > Selected > Undelete). It says restored expenses return to your account. It does not describe the bug, so nothing is out of date.
Moving expenses: The steps for moving an expense to a report do not change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
After delete → undelete, the self-DM has two IOU actions for the same transaction (the old blanked one plus the new live one). When the expense is moved, the lookup can pick the blanked one. The new action copies its blanked message, so the moved expense shows as deleted and the report loads forever. The live thread is never moved to the new report, so opening the expense shows "not here".
Fix: a new opt-in
shouldPreferLiveActionflag ongetIOUActionForReportID/getIOUActionForTransactionIDreturns the live action when both exist. In every other case it returns the same action as before. OnlygetChangeTransactionsReportOnyxDataanduseChangeTransactionsReportReportspass it. Added a regression test.Fixed Issues
$ #97677
PROPOSAL: #97677 (comment)
Tests
Prerequisite: Account has a Self DM and a workspace.
Offline tests
Same as Tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)Avatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
test.mov