Skip to content

fix: workspace change system message shows previous IOU report as long ID (undefined) #62466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2025
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
9 changes: 4 additions & 5 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ import {
getIOUForwardedMessage,
getMoneyRequestSpendBreakdown,
getParticipantsAccountIDsForDisplay,
getPolicyChangeMessage,
getPolicyName,
getReimbursementDeQueuedOrCanceledActionMessage,
getReimbursementQueuedActionMessage,
Expand Down Expand Up @@ -803,11 +804,7 @@ 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) ||
isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.MOVED)
) {
} else if (isActionableAddPaymentCard(lastReportAction) || 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 All @@ -822,6 +819,8 @@ function getLastMessageTextForReport(
lastMessageTextFromReport = getUpdateRoomDescriptionMessage(lastReportAction);
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.REOPENED)) {
lastMessageTextFromReport = getReopenedMessage();
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY)) {
lastMessageTextFromReport = getPolicyChangeMessage(lastReportAction);
}

// we do not want to show report closed in LHN for non archived report so use getReportLastMessage as fallback instead of lastMessageText from report
Expand Down
2 changes: 1 addition & 1 deletion src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function getPolicyRole(policy: OnyxInputOrEntry<Policy> | SearchPolicy, currentU
}

function getPolicyNameByID(policyID: string): string {
return allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]?.name ?? policyID;
return allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]?.name ?? '';
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4800,6 +4800,10 @@ function getReportNameInternal({
return getPolicyChangeLogDefaultTitleEnforcedMessage(parentReportAction);
}

if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY)) {
return getPolicyChangeMessage(parentReportAction);
}

if (isMoneyRequestAction(parentReportAction)) {
const originalMessage = getOriginalMessage(parentReportAction);
if (originalMessage?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) {
Expand Down
4 changes: 4 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import {
getIOUForwardedMessage,
getIOUReportActionDisplayMessage,
getOriginalReportID,
getPolicyChangeMessage,
getReimbursementDeQueuedOrCanceledActionMessage,
getReimbursementQueuedActionMessage,
getRejectedReportMessage,
Expand Down Expand Up @@ -622,6 +623,9 @@ const ContextMenuActions: ContextMenuAction[] = [
setClipboardMessage(getCardIssuedMessage({reportAction, shouldRenderHTML: true, policyID: report?.policyID, card}));
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
setClipboardMessage(getRemovedConnectionMessage(reportAction));
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY) {
const displayMessage = getPolicyChangeMessage(reportAction);
Clipboard.setString(displayMessage);
} else if (isActionableJoinRequest(reportAction)) {
const displayMessage = getJoinRequestMessage(reportAction);
Clipboard.setString(displayMessage);
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/PolicyUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ describe('PolicyUtils', () => {
expect(getPolicyNameByID('1')).toBe('testName');
});

it('should return the policyID if the name is not set', async () => {
it('should return the empty if the name is not set', async () => {
const policy: Policy = {
...createRandomPolicy(1, CONST.POLICY.TYPE.TEAM),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand All @@ -549,7 +549,7 @@ describe('PolicyUtils', () => {

await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}1`, policy);

expect(getPolicyNameByID('1')).toBe('1');
expect(getPolicyNameByID('1')).toBe('');
});
});

Expand Down