Repository navigation
Do not optimistically create the moved-expense system message when the destination report is a draft - #99721
Conversation
Gate MOVED / MOVEDTRANSACTION system messages out of the thread UI unless they already have a threaded child, so the doomed thread-creation call is never made and the Unexpected error creating this chat message stops appearing. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
| // Moved system messages can't be threaded server-side, so offering "Reply in thread" leads to a failed thread-creation call. | ||
| // Gate them out of the thread UI, but keep any moved actions that have already been legitimately threaded. |
There was a problem hiding this comment.
@MelvinBot Better to add in function jsdoc similar to others, not here
There was a problem hiding this comment.
Done — moved the note into the shouldDisableThread JSDoc as a new bullet alongside the other conditions, and removed the inline comment. Pushed as 4da019c.
|
🤖 Ran the testing steps from this PR on Web. Outcome: Setup performed: created a workspace, two manual expenses (Test Merchant A €25, Test Merchant B €40) each in its own report, submitted both reports, then used Spend → Expenses → "Move to report" to move Test Merchant A's expense into the Test Merchant B report — producing a MOVED system message.
ScreenshotsMoved expense system message rendered in chat
Report B now holds 2 expenses (€65.00) after the move — no error toast
Hover over the moved system message — no context-menu toolbar rendered
Baseline hover on a control message — also no toolbar (session-wide limitation)
|
Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
@codex review |
|
@MelvinBot review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
🤖 Code review of the diff. The change is correct and well-scoped, but it misses 1. 🔴
|
It's expected. Backends accepts thread for this system message Screen.Recording.2026-09-01.at.2.51.59.AM.mov |
|
🤖 Regression hunt on this diff. Test suites, typecheck, and a main-vs-branch behavior matrix were run; the context-menu UI check could not be completed (see bottom). Headline: all four new tests are vacuous — they pass with the fix removed. I verified this by executing code, not by reading it. Two real behavior regressions below that, both narrow. R1 🔴 The new tests can't fail — CI would green-light a revert of this PR
Proof — I neutralized only the new clause to Fix, also verified: add a real message to the two "should be disabled" mocks — message: [{type: 'COMMENT', html: 'moved this expense', text: 'moved this expense'}],With that added and the clause still neutralized, the tests correctly fail ( R2 🟡 An existing moved-action thread becomes unreachable once its reply count returns to 0
Every other door is already shut in that state — the "N replies" link needs Bounded: only bites threads created before this deploys. R3 🟡 "Join thread" disappears, and it was not broken client-sideMeasured by running the real
R4 🟡 The premise "moved actions can't be threaded server-side" is still unverified — and the diff contradicts itTwo in-repo signals point the other way:
I could not settle this from code, and the VictoriaLogs tooling wasn't available in this run, so treat it as genuinely open rather than as evidence either way. Someone with log access should check whether Checked and clean — no regression foundTest runs on
Web UI check — could not run (environment limitation)Outcome: ❌ Fail on the baseline step, so no conclusion about the menu itself. This is the same blocker as the earlier run on this PR, and it is not a finding about the code.
Evidence (3)Plain text message sent in Concierge chat
Hover attempt over a message row shows no toolbar or highlight
Hover attempt over LHN chat row shows no hover affordance (sanity check)
The "Reply in thread is absent" step still needs a human screenshot. Bottom line: R1 is the one to fix before merge — it's a two-line test change and without it the suite guards nothing. R2 and R3 are narrow and arguably acceptable, but belong in the PR description. R4 is the open question the whole change rests on. |
|
@MelvinBot address R1 in #99721 (comment) |
The mocks had no message field, so isDeletedAction treated them as legacy deleted comments and the pre-existing deleted-and-unthreaded clause already returned true. The new isMovedSystemMessage clause was never exercised, so the tests passed with it removed. Add a real message, matching the sibling archived/deleted cases in the same describe block. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
🤖 R1 fixed and pushed — The finding was right: the four mocks had no Added a real message to all four mocks, matching the sibling archived/deleted cases already in that Verified the tests are now load-bearing, by execution:
The two "already threaded" cases still pass with the clause neutralized — that's inherent to a negative assertion ( Checks run on 8f303e2
Only R2, R3 and R4 are untouched — say the word if you want any of them addressed. |
DetailsExplanation of ChangeMoved system messages ( The earlier fix (Expensify/App#95979) only closed the narrow "create report from a draft expense" repro. This change gates moved system messages out of the thread UI at the source, in I used the guarded approach from the issue rather than blanket-adding the actions to As noted in the issue, the backend root-cause (why the moved action can't be threaded at all) is tracked internally and is out of scope here — this is the defensive FE fix that stops the user-facing error. Fixed Issues$ #99653 Tests
Note: It's expected to show moved system message on the expense moved to personal space
Offline testsSame as Tests QA StepsSame as Tests
PR Author Checklist
@MelvinBot please set the PR body to the content in the details section above and mark as ready for review |
|
@mkhutornyi 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] |
|
🤖 Done — PR body replaced with the content from your details block, and the PR is now ready for review (no longer a draft). Two notes on the body you supplied:
|
|
@MelvinBot I noticed that "reply in thread" is enabled in backend when source report is draft report, destination report is submitted report. |
…raft The backend threads a MOVEDTRANSACTION system message when the expense lands in a submitted report, and refuses when it lands in a draft report. Blanket disabling hid Reply in thread on messages the backend would have threaded, so key the gate on the destination report instead. The destination is the parent of the transaction thread the action lives on, resolved in BaseReportActionContextMenu and passed through the context menu's shouldShow payload, which also keeps Join thread consistent with Reply in thread. MOVED (a report moved between workspaces) is unchanged. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
Done — the branch now matches the backend rule The code was already right. What I changed: the personal-space test only covered a draft source, so the confirmed "Any report → personal space" row wasn't fully encoded. Parametrized it over draft and submitted sources —
I also updated the PR description with that table and a link to your confirmation, so the reasoning isn't buried in the thread. The tests are load-bearing — I checked by execution, not by reading. Reverting the guard to Restored, all 81 tests across both Transaction suites pass. Checks run
Web verification failed on the environment, not the code. The dev server returned 200 and webpack built cleanly, but the app rendered a solid-white page with 0 accessibility nodes for ~11 minutes, so none of the four UI steps could be attempted. Steps 3–8 in the PR description still need a human screenshot. One thing outside this PR's scope, worth a second opinion: |
Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
@MelvinBot pull main and fix Oxfmt diff |
…nMovedSystemMessages Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
Done —
Checks run after the merge
The only remaining failure is |
dylanexpensify
left a comment
There was a problem hiding this comment.
good from a product perspective 👍
inimaga
left a comment
There was a problem hiding this comment.
@mkhutornyi Let me know when this is ready for review.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppios1.movios2.moviOS: mWeb SafariMacOS: Chrome / Safariweb.mov |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #99653 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
|
@MelvinBot pull main |
…nMovedSystemMessages Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
🤖 Merged
The branch is mergeable again. Checks are re-running on the new commit. |
@inimaga ready |
|
🚧 inimaga has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/inimaga in version: 9.4.73-0 🚀
|
|
🤖 Yes — help site changes were required. Draft PR: #100498 Two articles documented the old, source-based rule this PR replaced:
I verified the shipped behavior on dev NewDot web rather than reading it off the diff, and it matches your table:
Also corrected: stale UI labels in the move steps, and one thing for youWhile editing those steps in
Possible App bug, not a docs issue: for the Remove from report case, the rendered message reads "moved this expense from @mkhutornyi, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.4.73-3 🚀
Bundle Size Analysis (Sentry): |
…eport Expensify#99721 moved the optimistic MOVED_TRANSACTION guard from the source report to the destination report to match the backend. Update the two help articles that documented the old source-based rule, and correct the move-flow UI labels to match the current product. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>







Explanation of Change
Moving an expense into a draft (open) report optimistically created a
MOVEDTRANSACTIONsystem message that the backend never creates. That phantom action stayed in Onyx, so anything acting on it — most visibly "Reply in thread" — fired a request against areportActionIDthe server had never seen and surfaced "Unexpected error creating this chat. Please try again later."The earlier fix (Expensify/App#95979) guarded on the source report being a draft. That's the wrong side of the move.
inimagaconfirmed the backend rule — only the destination matters:MOVEDTRANSACTIONMOVEDTRANSACTIONUNREPORTEDTRANSACTIONSo
draft → submittedwas suppressed in the app even though the backend does create the message, andsubmitted → draftwas still built optimistically even though the backend doesn't.This flips the guard to the destination report in
src/libs/actions/Transaction.ts:Moving to personal space still builds the
UNREPORTEDTRANSACTIONmessage, unchanged.Unit tests cover every row of that table.
Fixed Issues
$ #99653
Tests
Note: It's expected to show moved system message on the expense moved to personal space
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.