Skip to content

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

Draft
MelvinBot wants to merge 2 commits into
mainfrom
claude-movedReportWorkspaceName-nyomanjyotisa
Draft

Fix: use server-rendered message for moved-report action when destination policy is unavailable locally#98238
MelvinBot wants to merge 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.

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.

2 participants