Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7277,6 +7277,14 @@ function getMovedActionMessage(translate: LocalizedTranslate, action: ReportActi
}
const {toPolicyID, newParentReportID, movedReportID} = movedActionOriginalMessage;
const toPolicyName = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${toPolicyID}`]?.name ?? '';

// The destination policy may not be in Onyx for everyone (e.g. a participant who isn't a member of the
// workspace the report was moved to), which would make toPolicyName empty and render a blank workspace name.
// In that case fall back to the workspace name already baked into the action's stored message.
if (!toPolicyName) {
return getReportActionHtml(action) || getReportActionText(action);
}

return translate('iou.movedAction', !isDM(report), getReportURLForCurrentContext(movedReportID), getReportURLForCurrentContext(newParentReportID), toPolicyName);
}

Expand Down
5 changes: 5 additions & 0 deletions tests/ui/ReportActionItemTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,11 @@ describe('ReportActionItem', () => {
newParentReportID: 'report2',
movedReportID: 'report3',
});
// The destination policy must be in Onyx so getMovedActionMessage resolves the workspace name and
// renders the translated "moved this ... workspace" message instead of falling back to the stored html.
await act(async () => {
await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}policy1`, {id: 'policy1', name: 'Test Workspace'});
});
renderItemWithAction(action);
await waitForBatchedUpdatesWithAct();

Expand Down
Loading