Skip to content

Fix: use server-rendered message for moved-report action when destination policy is unavailable locally - #98238

Merged
aldo-expensify merged 2 commits into
mainfrom
claude-movedReportWorkspaceName-nyomanjyotisa
Aug 12, 2026
Merged

Fix: use server-rendered message for moved-report action when destination policy is unavailable locally#98238
aldo-expensify merged 2 commits into
mainfrom
claude-movedReportWorkspaceName-nyomanjyotisa

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

The workspace name in the "moved this report to the … workspace" system message was recomputed on every render from the current user's local Onyx policy collection, with a bare empty-string fallback:

const toPolicyName = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${toPolicyID}`]?.name ?? '';

When User A is not a member of the destination workspace and never opened it, policy_<toPolicyID> isn't in their Onyx, so the lookup returns '' and the message renders with a blank name. It only appeared later because creating another expense delivered that policy into User A's COLLECTION.POLICY, after which the message re-rendered correctly.

This change makes getMovedActionMessage fall back to the server-rendered action message (getReportActionHtml(action)) when the destination policy isn't available locally (so toPolicyName would be empty). The broadcast action already carries the name the server rendered, so User A sees it immediately. When the policy is present locally, the current live-computed string is kept so nothing else changes. This mirrors the existing pattern where messages fall back to the stored action text when their computed inputs aren't available. Returning the stored HTML covers both consumption paths — the HTML-rendered report view and the plain-text LHN/preview callers that wrap the result in Parser.htmlToText(...).

A unit test was added covering the fallback path (destination policy absent locally → stored action HTML returned).

Fixed Issues

$ #98108
PROPOSAL: #98108 (comment)

Tests

  1. Sign in as User A.
  2. Create a manual expense for User B.
  3. As User B, open the expense report and select Pay → Pay with business account.
  4. Cancel the bank-account setup and verify the expense moves to User B’s workspace.
  5. As User A, open the DM with User B without opening the workspace chat.
  6. Verify the moved-report message and LHN preview immediately show the workspace name.
  • Verify that no errors appear in the JS console

Offline tests

  1. Complete the tests above.
  2. Enable Force offline.
  3. Navigate away and reopen the DM.
  4. Verify the moved-report message and LHN preview still show the workspace name.
  5. Disable Force offline.

QA Steps

Same as Tests and Offline 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 followed proper code patterns (see Reviewing the code)
    • 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 followed the guidelines as stated in the Review Guidelines
  • 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 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.

Screenshots/Videos

Android: Native
Android-pr98238.mp4
Android: mWeb Chrome
Android-mWeb-pr98238.mp4
iOS: Native
ios-pr98238.mp4
iOS: mWeb Safari
ios-mWeb-pr98238.mp4
MacOS: Chrome / Safari
Chrome-pr98238.mp4

…tion policy is unavailable locally

Co-authored-by: Nyoman Jyotisa <nyomanjyotisa@users.noreply.github.com>
…s live

Co-authored-by: Nyoman Jyotisa <nyomanjyotisa@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Fixed the failing check. Pushed 2f4ce0b.

What was failing: test (job 5)ReportActionItem › System notification actions › MOVED action renders moved message at tests/ui/ReportActionItemTest.tsx:1585.

Root cause (directly from this PR's change): the test's MOVED action uses toPolicyID: 'policy1', which is never added to Onyx. The new fallback in getMovedActionMessage now returns the stored action HTML whenever the destination policy is absent locally. The shared createReportAction test helper stubs message as 'some message', so the action rendered some message instead of the live-computed "moved this…" text, failing the /moved this/i assertion.

Fix: seed policy1 into Onyx in that test (mirroring the existing MODIFIED_EXPENSE test) so it exercises the member/live-computed path and renders the real moved message. No production code changed.

Other non-passing checks (not addressed — not code failures)
  • build (Expensify Dev, Debug, true) — infra failure, unrelated to this PR. The iOS Rock remote build failed installing CocoaPods deps: Error installing React-Core-prebuiltcurl: (56) The requested URL returned error: 401. This is a prebuilt-artifact download auth issue in CI, not something in the diff. It should clear on re-run.
  • checklist and Check independent approval — these are the standard author/approval checklist gates, not CI test failures.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The real failure is already fixed by my earlier push (2f4ce0b). Re-running the checks confirms it:

  • All 8 test jobs now pass, including the previously-failing test (job 5) (MOVED action renders moved message).
  • typecheck and the iOS build both pass (the earlier build failure was a transient CI CocoaPods 401, now cleared).

The only checks still showing as failed are checklist and Check independent approval — these are the standard PR author-checklist / approval gates, not CI test failures, and require human action (completing the checklist / getting an independent review). Nothing further for me to fix here.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The code-related failures are resolved by my earlier push (2f4ce0b) — all 8 test (job N) shards now pass, including test (job 5) which was the real failure.

The only checks still red are checklist and Check independent approval. These aren't CI/test failures — they're the standard PR-author checklist and independent-approval gates, which need human action (complete the checklist items / obtain an independent reviewer's approval). There's nothing for me to push here.

@nyomanjyotisa

Copy link
Copy Markdown
Member
Updated PR description

Tests

  1. Sign in as User A.
  2. Create a manual expense for User B.
  3. As User B, open the expense report and select Pay → Pay with business account.
  4. Cancel the bank-account setup and verify the expense moves to User B’s workspace.
  5. As User A, open the DM with User B without opening the workspace chat.
  6. Verify the moved-report message and LHN preview immediately show the workspace name.
  • Verify that no errors appear in the JS console

Offline tests

  1. Complete the tests above.
  2. Enable Force offline.
  3. Navigate away and reopen the DM.
  4. Verify the moved-report message and LHN preview still show the workspace name.
  5. Disable Force offline.

QA Steps

Same as Tests and Offline 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 followed proper code patterns (see Reviewing the code)
    • 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 followed the guidelines as stated in the Review Guidelines
  • 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 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.

Screenshots/Videos

Android: Native
Android-pr98238.mp4
Android: mWeb Chrome
Android-mWeb-pr98238.mp4
iOS: Native
ios-pr98238.mp4
iOS: mWeb Safari
ios-mWeb-pr98238.mp4
MacOS: Chrome / Safari
Chrome-pr98238.mp4

@MelvinBot please replace the PR description from ### Tests through ### Screenshots/Videos with the content in the details section above.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

✅ Done — I replaced the PR description from ### Tests through ### Screenshots/Videos with your updated content (Tests, Offline tests, QA Steps, the completed PR Author Checklist, and the platform screenshots/videos). The ### Explanation of Change and ### Fixed Issues sections above were left untouched.

@nyomanjyotisa

Copy link
Copy Markdown
Member

Reviewer Checklist

  • 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 proper code patterns were followed (see Reviewing the code)
    • 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
    • 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
    • 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 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.

Screenshots/Videos

Android: HybridApp
Android-pr98238.mp4
Android: mWeb Chrome
Android-mWeb-pr98238.mp4
iOS: HybridApp
ios-pr98238.mp4
iOS: mWeb Safari
ios-mWeb-pr98238.mp4
MacOS: Chrome / Safari
Chrome-pr98238.mp4

@nyomanjyotisa

Copy link
Copy Markdown
Member

@MelvinBot please mark this PR as ready for review.

@MelvinBot
MelvinBot marked this pull request as ready for review August 12, 2026 04:38
@MelvinBot
MelvinBot requested a review from a team as a code owner August 12, 2026 04:38
@melvin-bot
melvin-bot Bot requested review from heyjennahay and nyomanjyotisa and removed request for a team August 12, 2026 04:38
@melvin-bot

melvin-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

@nyomanjyotisa 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]

@MelvinBot

Copy link
Copy Markdown
Contributor Author

✅ Marked this PR as ready for review.

All CI checks are passing except Check independent approval, which stays red until a reviewer independently approves — expected for a PR that hasn't been reviewed yet.

@nyomanjyotisa nyomanjyotisa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@melvin-bot
melvin-bot Bot requested a review from aldo-expensify August 12, 2026 05:02
@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 I looked into this — there are no failing code checks to fix. Every test/lint/typecheck job is green (Bun tests, test (job 1–8), typecheck, ESLint, Oxfmt, Storybook, Reassure, etc.), and the PR is currently MERGEABLE with a CLEAN merge state.

The only red mark in the status rollup is a stale PR Author Checklist / checklist run (run 31456262261) from the very first push, when the author checklist boxes weren't yet ticked. It's already been superseded by a passing re-run (run 31502690701), so GitHub no longer counts it against the merge state.

Nothing to push here. If GitHub is still showing that old run as failing in the UI, a no-op re-run of the "PR Author Checklist" workflow will clear the stale status.

@aldo-expensify

Copy link
Copy Markdown
Contributor

I'll just merge this since we are just fixing a bug (missing policy name) and not changing the product

@aldo-expensify
aldo-expensify merged commit 7a3e3cd into main Aug 12, 2026
39 of 42 checks passed
@aldo-expensify
aldo-expensify deleted the claude-movedReportWorkspaceName-nyomanjyotisa branch August 12, 2026 05:09
@github-actions

Copy link
Copy Markdown
Contributor

🚧 aldo-expensify has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/aldo-expensify in version: 9.4.53-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Help site review — no docs changes required

I reviewed the changes in this PR and no updates to Expensify's help site (App/docs/articles) are needed, so I did not open a draft docs PR.

Why: This is an internal rendering bug fix, not a behavior or feature change. The getMovedActionMessage fix makes the "moved this report to the … workspace" system message fall back to the server-rendered text when the destination policy isn't available in the current user's local Onyx, so the workspace name shows immediately instead of appearing blank until another update arrives.

Nothing user-facing changed that the help site documents:

  • No new or renamed feature, setting, tab, or button.
  • No change to how a user moves a report/expense to a workspace — only the correct display of an existing system message.
  • The remaining changes are unit/UI tests.

Help articles like Managing Expenses in a Report and Expense and Report Actions describe the moved-report workflow, and both remain accurate as-is.

@nyomanjyotisa, since no help site changes were required, no draft docs PR was opened. If you believe an article should still be updated, let me know and I'll create one.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants