Skip to content

Fix: Workspace name blank in moved-report system message for non-members - #98112

Closed
MelvinBot wants to merge 2 commits into
mainfrom
claude-movedReportWorkspaceName
Closed

MelvinBot wants to merge 2 commits into
mainfrom
claude-movedReportWorkspaceName

Conversation

@MelvinBot

Copy link
Copy Markdown
Contributor

Explanation of Change

The moved-report system message ("moved this report to the [Workspace name] workspace") resolved the workspace name only from the current user's local Onyx POLICY collection (getMovedActionMessage in ReportUtils.ts). For a viewer who isn't a member of the destination workspace (e.g. the DM participant in the linked issue who never opened that workspace), the policy isn't in Onyx, so the name resolved to an empty string and the message rendered a blank workspace name. It only appeared later once an unrelated action delivered the policy into Onyx.

This change makes getMovedActionMessage fall back to the workspace name already baked into the action's stored message (message[0].html, then text) when the destination policy isn't available locally, so the name renders correctly for all participants. CHANGE_POLICY is intentionally left out of scope.

Fixed Issues

$ #98108
PROPOSAL: #98108 (comment)

Tests

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • 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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

When the destination policy isn't in Onyx for a viewer (e.g. a participant who
isn't a member of the workspace the report was moved to), getMovedActionMessage
resolved an empty workspace name. Fall back to the name already stored in the
action's message (html/text) so the system message renders correctly.

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

Copy link
Copy Markdown
Contributor Author

Fixed the failing check. 🎯

What was failing: test (job 5) → tests/ui/ReportActionItemTest.tsx → "MOVED action renders moved message" (Unable to find an element with text: /moved this/i). All other red checks (checklist, Check independent approval) are the standard human checklist gates, not code failures.

Why it broke: The test creates a MOVED action with toPolicyID: 'policy1' but never seeds policy1 into Onyx, and createReportAction hardcodes the action's stored message as 'some message'. Before this PR, an empty toPolicyName still went through the translate('iou.movedAction', …) path and rendered "moved this report to the …workspace", so the assertion passed. This PR's new fallback in getMovedActionMessage instead returns the stored html ('some message') when the destination policy isn't in Onyx — which is exactly the intended fix, but it made the test render 'some message' instead of 'moved this…'.

Fix: Seed policy1 into Onyx in the test so it exercises the normal name-resolution path and renders the translated moved message (test change). The test now reflects real production data, where a MOVED action's stored message is a proper moved message rather than a placeholder.

I couldn't execute Jest in this environment to confirm locally, but the change is deterministic — with policy1 present, toPolicyName resolves to "Test Workspace" and movedAction renders moved this report to the Test Workspace workspace, which matches /moved this/i. CI will re-run to confirm.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

All the code checks are green now. ✅

The earlier failure (test (job 5) → "MOVED action renders moved message") was fixed by my previous push (4e03b9c), and the latest run confirms tests, typecheck, ESLint, Oxfmt, React Compiler, and the rest all pass.

The only two remaining red checks are PR Author Checklist / checklist and Check independent approval — these are the standard human-completed gates (author checklist + reviewer approval), not code failures, so there's nothing for me to push. They'll clear once the checklist is filled in and the PR gets its required approval.

@nyomanjyotisa

Copy link
Copy Markdown
Member

@MelvinBot Please close this PR. The proposal has not been approved by a CME yet.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Closing this PR as requested — the underlying proposal hasn't been approved by a CME yet. Feel free to reopen once the proposal is approved. 👍

@MelvinBot MelvinBot closed this Aug 10, 2026
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