diff --git a/cspell.json b/cspell.json index ed2cbd7589da..a1381504cb01 100644 --- a/cspell.json +++ b/cspell.json @@ -902,7 +902,9 @@ "Synovus", "Wallester", "Wintrust", - "Zürcher" + "Zürcher", + "CARDFROZEN", + "CARDUNFROZEN" ], "ignorePaths": [ "src/languages/de.ts", diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 214515187b7e..0ff05f03fadf 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -1394,6 +1394,8 @@ const CONST = { CARD_REPLACED_VIRTUAL: 'CARDREPLACEDVIRTUAL', CARD_REPLACED: 'CARDREPLACED', CARD_ASSIGNED: 'CARDASSIGNED', + CARD_FROZEN: 'CARDFROZEN', + CARD_UNFROZEN: 'CARDUNFROZEN', PERSONAL_CARD_CONNECTION_BROKEN: 'PERSONALCARDCONNECTIONBROKEN', CHANGE_FIELD: 'CHANGEFIELD', // OldDot Action CHANGE_POLICY: 'CHANGEPOLICY', diff --git a/src/pages/inbox/report/PureReportActionItem.tsx b/src/pages/inbox/report/PureReportActionItem.tsx index 1c27992a8f64..1257050fb9cc 100644 --- a/src/pages/inbox/report/PureReportActionItem.tsx +++ b/src/pages/inbox/report/PureReportActionItem.tsx @@ -123,6 +123,7 @@ import { getRemovedFromApprovalChainMessage, getRenamedAction, getRenamedCardFeedMessage, + getReportActionHtml, getReportActionMessage, getReportActionText, getSetAutoJoinMessage, @@ -1523,6 +1524,12 @@ function PureReportActionItem({ children = } />; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CARD_FROZEN || action.actionName === CONST.REPORT.ACTIONS.TYPE.CARD_UNFROZEN) { + children = ( + + ${getReportActionHtml(action)}`} /> + + ); } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) { children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.RESOLVED_DUPLICATES)) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index b0fbe7901eff..fbab4788dbb0 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -1298,6 +1298,20 @@ type OriginalMessageCard = { hadMissingAddress?: boolean; }; +/** + * Model of CARDFROZEN action + */ +type OriginalMessageCardFrozen = { + /** HTML content of the system message */ + html: string; + + /** Whether the action was generated by NewDot */ + isNewDot?: boolean; + + /** When the action was last modified */ + lastModified?: string; +}; + /** * Model of PERSONAL_CARD_CONNECTION_BROKEN action */ @@ -1352,7 +1366,7 @@ type OriginalMessageSettlementAccountLocked = { }; /** - * Original message for CARD_ISSUED, CARD_MISSING_ADDRESS, CARD_ASSIGNED, CARD_ISSUED_VIRTUAL and CARD_ISSUED_VIRTUAL actions + * Original message for Expensify Card issue/replacement actions */ type IssueNewCardOriginalMessage = OriginalMessage< | typeof CONST.REPORT.ACTIONS.TYPE.CARD_MISSING_ADDRESS @@ -1469,6 +1483,8 @@ type OriginalMessageMap = { [CONST.REPORT.ACTIONS.TYPE.CARD_REPLACED_VIRTUAL]: OriginalMessageCard; [CONST.REPORT.ACTIONS.TYPE.CARD_REPLACED]: OriginalMessageCard; [CONST.REPORT.ACTIONS.TYPE.CARD_ASSIGNED]: OriginalMessageCard; + [CONST.REPORT.ACTIONS.TYPE.CARD_FROZEN]: OriginalMessageCardFrozen; + [CONST.REPORT.ACTIONS.TYPE.CARD_UNFROZEN]: OriginalMessageCardFrozen; [CONST.REPORT.ACTIONS.TYPE.PERSONAL_CARD_CONNECTION_BROKEN]: OriginalPersonalCard; [CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED]: OriginalMessageIntegrationSyncFailed; [CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION]: OriginalMessageDeletedTransaction; diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index 1f59950c971d..20f0bdc26c1c 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -1387,6 +1387,109 @@ describe('ReportActionsUtils', () => { const expectedHtml = `${expectedText}`; expect(fragments).toEqual([{text: expectedText, html: expectedHtml, type: 'COMMENT'}]); }); + + it('should preserve backend-provided CARDFROZEN fragments', () => { + const cardFrozenMessage = 'A A froze their Expensify Card (ending in 1384). New transactions will be declined until the card is unfrozen.'; + const action: ReportAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.CARD_FROZEN, + reportActionID: 'card-frozen-action-123', + actorAccountID: 21052128, + created: '2026-03-12 01:58:43.479', + message: [ + { + html: cardFrozenMessage, + text: cardFrozenMessage, + type: CONST.REPORT.MESSAGE.TYPE.COMMENT, + whisperedTo: [], + }, + ], + originalMessage: { + html: cardFrozenMessage, + isNewDot: true, + lastModified: '2026-03-12 01:58:43.479', + }, + }; + + expect(ReportActionsUtils.getReportActionMessageFragments(translateLocal, action)).toEqual(action.message); + }); + + it('should preserve backend-provided CARDUNFROZEN fragments', () => { + const cardUnfrozenMessage = 'A A unfroze their Expensify Card (ending in 1384). This card can now be used for transactions.'; + const action: ReportAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.CARD_UNFROZEN, + reportActionID: 'card-unfrozen-action-123', + actorAccountID: 21052128, + created: '2026-03-12 02:08:08.128', + message: [ + { + html: cardUnfrozenMessage, + text: cardUnfrozenMessage, + type: CONST.REPORT.MESSAGE.TYPE.COMMENT, + whisperedTo: [], + }, + ], + originalMessage: { + html: cardUnfrozenMessage, + isNewDot: true, + lastModified: '2026-03-12 02:08:08.128', + }, + }; + + expect(ReportActionsUtils.getReportActionMessageFragments(translateLocal, action)).toEqual(action.message); + }); + }); + + describe('getReportActionText', () => { + it('should return the backend-provided CARDFROZEN text', () => { + const cardFrozenMessage = 'A A froze their Expensify Card (ending in 1384). New transactions will be declined until the card is unfrozen.'; + const action: ReportAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.CARD_FROZEN, + reportActionID: 'card-frozen-action-123', + actorAccountID: 21052128, + created: '2026-03-12 01:58:43.479', + message: [ + { + html: cardFrozenMessage, + text: cardFrozenMessage, + type: CONST.REPORT.MESSAGE.TYPE.COMMENT, + whisperedTo: [], + }, + ], + originalMessage: { + html: cardFrozenMessage, + isNewDot: true, + lastModified: '2026-03-12 01:58:43.479', + }, + }; + + expect(ReportActionsUtils.getReportActionText(action)).toBe(cardFrozenMessage); + }); + + it('should return the backend-provided CARDUNFROZEN text', () => { + const cardUnfrozenMessage = 'A A unfroze their Expensify Card (ending in 1384). This card can now be used for transactions.'; + const action: ReportAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.CARD_UNFROZEN, + reportActionID: 'card-unfrozen-action-123', + actorAccountID: 21052128, + created: '2026-03-12 02:08:08.128', + message: [ + { + html: cardUnfrozenMessage, + text: cardUnfrozenMessage, + type: CONST.REPORT.MESSAGE.TYPE.COMMENT, + whisperedTo: [], + }, + ], + originalMessage: { + html: cardUnfrozenMessage, + isNewDot: true, + lastModified: '2026-03-12 02:08:08.128', + }, + }; + + expect(ReportActionsUtils.getReportActionText(action)).toBe(cardUnfrozenMessage); + expect(ReportActionsUtils.shouldReportActionBeVisible(action, action.reportActionID, true)).toBe(true); + }); }); describe('getMessageOfOldDotReportAction', () => { @@ -1665,6 +1768,30 @@ describe('ReportActionsUtils', () => { const reportAction = buildOptimisticCreatedReportForUnapprovedAction('123456', '789012'); expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(false); }); + + it('should return false for CARDFROZEN action with a backend-provided message fragment', () => { + const reportAction: ReportAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.CARD_FROZEN, + reportActionID: 'card-frozen-action-123', + actorAccountID: 21052128, + created: '2026-03-12 01:58:43.479', + message: [ + { + html: 'A A froze their Expensify Card (ending in 1384). New transactions will be declined until the card is unfrozen.', + text: 'A A froze their Expensify Card (ending in 1384). New transactions will be declined until the card is unfrozen.', + type: CONST.REPORT.MESSAGE.TYPE.COMMENT, + whisperedTo: [], + }, + ], + originalMessage: { + html: 'A A froze their Expensify Card (ending in 1384). New transactions will be declined until the card is unfrozen.', + isNewDot: true, + lastModified: '2026-03-12 01:58:43.479', + }, + }; + + expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(false); + }); }); describe('getRenamedAction', () => { @@ -1728,7 +1855,6 @@ describe('ReportActionsUtils', () => { } as Card; const testPolicyID = 'test-policy-123'; - describe('render virtual card issued messages', () => { it('should render a plain text message without card link when no card data is available', () => { const messageResult = getCardIssuedMessage({