Skip to content
Merged
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
6 changes: 5 additions & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,11 @@ function getLastMessageTextForReport(
lastMessageTextFromReport = getUpgradeWorkspaceMessage();
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) {
lastMessageTextFromReport = getDowngradeWorkspaceMessage();
} else if (isActionableAddPaymentCard(lastReportAction) || isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY)) {
} else if (
isActionableAddPaymentCard(lastReportAction) ||
isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY) ||
isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.MOVED)
) {
lastMessageTextFromReport = getReportActionMessageText(lastReportAction);
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION) {
lastMessageTextFromReport = getExportIntegrationLastMessageText(lastReportAction);
Expand Down
66 changes: 66 additions & 0 deletions tests/unit/SidebarUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,72 @@ describe('SidebarUtils', () => {
// Then the alternate text should be equal to the message of the last action prepended with the last actor display name.
expect(result?.alternateText).toBe(`You invited 1 member`);
});
it('returns the last action message as an alternate text if the action is MOVED type', async () => {
// When a report has last action of MOVED type
const policy: Policy = {
...createRandomPolicy(1),
pendingAction: null,
};
const session = {
authToken: 'sensitive-auth-token',
encryptedAuthToken: 'sensitive-encrypted-token',
email: 'user@example.com',
accountID: 12345,
};
const report: Report = {
...createRandomReport(4),
chatType: 'policyRoom',
lastMessageHtml: '',
lastMessageText: '',
lastVisibleActionCreated: '2025-04-27 12:30:03.784',
participants: {
'12345': {
notificationPreference: 'daily',
},
},
policyID: '1',
};
const lastAction: ReportAction = {
...createRandomReportAction(2),
message: [
{
type: 'COMMENT',
html: "moved this report to the <a href='https://new.expensify.com/r/1325702002189143' target='_blank' rel='noreferrer noopener'>Three&#039;s Workspace</a> workspace",
text: "moved this report to the Three's Workspace workspace",
isEdited: false,
whisperedTo: [],
isDeletedParentAction: false,
deleted: '',
},
],
originalMessage: {
lastModified: '2025-04-27 12:32:10.416',
targetAccountIDs: [19268914],
},
actorAccountID: 12345,
actionName: CONST.REPORT.ACTIONS.TYPE.MOVED,
};
const reportActions: ReportActions = {[lastAction.reportActionID]: lastAction};
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report);
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, reportActions);
await Onyx.set(ONYXKEYS.SESSION, session);
await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}1`, policy);
const result = SidebarUtils.getOptionData({
report,
reportAttributes: {},
reportActions,
reportNameValuePairs: {},
hasViolations: false,
personalDetails: {},
policy: undefined,
parentReportAction: undefined,
preferredLocale: CONST.LOCALES.EN,
oneTransactionThreadReport: undefined,
});

// Then the alternate text should be equal to the message of the last action prepended with the last actor display name.
expect(result?.alternateText).toBe(`${lastAction.person?.[0].text}: ${getReportActionMessageText(lastAction)}`);
});
});
});
});