diff --git a/src/CONST/index.ts b/src/CONST/index.ts index b57157175889..e06107ab6212 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -1579,6 +1579,7 @@ const CONST = { UPDATE_ADDRESS: 'POLICYCHANGELOG_UPDATE_ADDRESS', UPDATE_FEATURE_ENABLED: 'POLICYCHANGELOG_UPDATE_FEATURE_ENABLED', UPDATE_IS_ATTENDEE_TRACKING_ENABLED: 'POLICYCHANGELOG_UPDATE_IS_ATTENDEE_TRACKING_ENABLED', + UPDATE_REQUIRE_COMPANY_CARDS_ENABLED: 'POLICYCHANGELOG_UPDATE_REQUIRE_COMPANY_CARDS_ENABLED', UPDATE_DEFAULT_APPROVER: 'POLICYCHANGELOG_UPDATE_DEFAULT_APPROVER', UPDATE_SUBMITS_TO: 'POLICYCHANGELOG_UPDATE_SUBMITS_TO', UPDATE_FORWARDS_TO: 'POLICYCHANGELOG_UPDATE_FORWARDS_TO', diff --git a/src/languages/de.ts b/src/languages/de.ts index 22a643a809bc..6d1afd30de42 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -7534,6 +7534,7 @@ Fügen Sie weitere Ausgabelimits hinzu, um den Cashflow Ihres Unternehmens zu sc `Kartenfeed-Tag für das Abrechnungsperiodenende von „${feedName}“ geändert${newValue ? ` in „${newValue}“` : ''}${previousValue ? ` (zuvor „${previousValue}“)` : ''}`, addedReportField: (fieldType: string, fieldName?: string, defaultValue?: string) => `${fieldType}-Berichtsfeld „${fieldName}“${defaultValue ? ` mit Standardwert „${defaultValue}“` : ''} hinzugefügt`, + updatedRequireCompanyCards: ({enabled}: {enabled: boolean}) => `${enabled ? 'aktiviert' : 'deaktiviert'} die Anforderung für Firmenkartenkäufe`, }, roomMembersPage: { memberNotFound: 'Mitglied nicht gefunden.', diff --git a/src/languages/en.ts b/src/languages/en.ts index ac6e1b0ae3f8..eb2c068e2993 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -7421,6 +7421,7 @@ const translations = { } }, updatedAttendeeTracking: ({enabled}: {enabled: boolean}) => `${enabled ? 'enabled' : 'disabled'} attendee tracking`, + updatedRequireCompanyCards: ({enabled}: {enabled: boolean}) => `${enabled ? 'enabled' : 'disabled'} the company card purchases requirement`, updatedAutoPayApprovedReports: ({enabled}: {enabled: boolean}) => `${enabled ? 'enabled' : 'disabled'} auto-pay approved reports`, setAutoPayApprovedReportsLimit: ({newLimit}: {newLimit: string}) => `set the auto-pay approved reports threshold to "${newLimit}"`, updatedAutoPayApprovedReportsLimit: ({oldLimit, newLimit}: {oldLimit: string; newLimit: string}) => diff --git a/src/languages/es.ts b/src/languages/es.ts index 29156f668452..74e9c0ad7173 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -7287,6 +7287,7 @@ ${amount} para ${merchant} - ${date}`, } }, updatedAttendeeTracking: ({enabled}: {enabled: boolean}) => `${enabled ? 'habilitó' : 'deshabilitó'} el seguimiento de asistentes`, + updatedRequireCompanyCards: ({enabled}: {enabled: boolean}) => `${enabled ? 'habilitó' : 'deshabilitó'} el requisito de compras con tarjeta de la empresa`, updatedAutoPayApprovedReports: ({enabled}: {enabled: boolean}) => `${enabled ? 'habilitó' : 'deshabilitó'} el autopago de informes aprobados`, setAutoPayApprovedReportsLimit: ({newLimit}: {newLimit: string}) => `estableció el umbral de autopago de informes aprobados en "${newLimit}"`, updatedAutoPayApprovedReportsLimit: ({oldLimit, newLimit}: {oldLimit: string; newLimit: string}) => diff --git a/src/languages/fr.ts b/src/languages/fr.ts index f843b122e0b9..97ce8b68e05f 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -7556,6 +7556,7 @@ Ajoutez davantage de règles de dépenses pour protéger la trésorerie de l’e `a modifié le jour de fin de période de relevé du flux de carte « ${feedName} »${newValue ? ` à « ${newValue} »` : ''}${previousValue ? ` (précédemment « ${previousValue} »)` : ''}`, addedReportField: (fieldType: string, fieldName?: string, defaultValue?: string) => `a ajouté le champ de note de frais ${fieldType} « ${fieldName} »${defaultValue ? ` avec la valeur par défaut « ${defaultValue} »` : ''}`, + updatedRequireCompanyCards: ({enabled}: {enabled: boolean}) => `${enabled ? 'activé' : 'désactivé'} l’exigence d’achats par carte d’entreprise`, }, roomMembersPage: { memberNotFound: 'Membre introuvable.', diff --git a/src/languages/it.ts b/src/languages/it.ts index 99832c489074..57342d86f77b 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -7522,6 +7522,7 @@ Aggiungi altre regole di spesa per proteggere il flusso di cassa aziendale.`, `ha modificato il giorno di fine periodo dell’estratto conto del flusso carta "${feedName}"${newValue ? ` a "${newValue}"` : ''}${previousValue ? ` (in precedenza "${previousValue}")` : ''}`, addedReportField: (fieldType: string, fieldName?: string, defaultValue?: string) => `aggiunto campo di report ${fieldType} "${fieldName}"${defaultValue ? ` con valore predefinito "${defaultValue}"` : ''}`, + updatedRequireCompanyCards: ({enabled}: {enabled: boolean}) => `${enabled ? 'abilitato' : 'disabilitato'} il requisito per gli acquisti con carta aziendale`, }, roomMembersPage: { memberNotFound: 'Membro non trovato.', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index dc4e57359dd0..bcd7b7c5ec93 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -7432,6 +7432,7 @@ ${reportName} `カード明細フィード「${feedName}」の利用明細期間の終了日を変更しました${newValue ? ` を「${newValue}」に` : ''}${previousValue ? ` (以前の値:「${previousValue}」)` : ''}`, addedReportField: (fieldType: string, fieldName?: string, defaultValue?: string) => `${fieldType}レポートフィールド「${fieldName}」を追加しました${defaultValue ? ` デフォルト値「${defaultValue}」付き` : ''}`, + updatedRequireCompanyCards: ({enabled}: {enabled: boolean}) => `${enabled ? '有効' : '無効'} の法人カード購入要件`, }, roomMembersPage: { memberNotFound: 'メンバーが見つかりません。', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 641ab4a6afe1..45be5bc22e55 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -7497,6 +7497,7 @@ er bestedingsregels toe om de kasstroom van het bedrijf te beschermen.`, `heeft de einddag van de afrekenperiode van kaartfeed "${feedName}" gewijzigd${newValue ? ` naar "${newValue}"` : ''}${previousValue ? ` (voorheen "${previousValue}")` : ''}`, addedReportField: (fieldType: string, fieldName?: string, defaultValue?: string) => `heeft ${fieldType}-rapportveld "${fieldName}" toegevoegd${defaultValue ? ` met standaardwaarde "${defaultValue}"` : ''}`, + updatedRequireCompanyCards: ({enabled}: {enabled: boolean}) => `vereiste ${enabled ? 'ingeschakeld' : 'uitgeschakeld'} voor bedrijfskaarttransacties`, }, roomMembersPage: { memberNotFound: 'Lid niet gevonden.', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index f98b52f16f15..03fa826e7161 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -7488,6 +7488,7 @@ Dodaj więcej zasad wydatków, żeby chronić płynność finansową firmy.`, `zmienił dzień zakończenia okresu rozliczeniowego dla źródła karty „${feedName}”${newValue ? ` na „${newValue}”` : ''}${previousValue ? ` (wcześniej „${previousValue}”)` : ''}`, addedReportField: (fieldType: string, fieldName?: string, defaultValue?: string) => `dodano pole raportu typu ${fieldType} „${fieldName}”${defaultValue ? ` z domyślną wartością „${defaultValue}”` : ''}`, + updatedRequireCompanyCards: ({enabled}: {enabled: boolean}) => `${enabled ? 'włączone' : 'wyłączone'} wymóg dotyczący zakupów kartą służbową`, }, roomMembersPage: { memberNotFound: 'Nie znaleziono członka.', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 3fa012250fe2..b8d610092b56 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -7489,6 +7489,7 @@ Adicione mais regras de gasto para proteger o fluxo de caixa da empresa.`, `changed card feed "${feedName}" statement period end day${newValue ? ` para "${newValue}"` : ''}${previousValue ? `(antes " ${previousValue}")` : ''}`, addedReportField: (fieldType: string, fieldName?: string, defaultValue?: string) => `adicionou o campo de relatório ${fieldType} "${fieldName}"${defaultValue ? ` com valor padrão "${defaultValue}"` : ''}`, + updatedRequireCompanyCards: ({enabled}: {enabled: boolean}) => `${enabled ? 'ativado' : 'desativado'} o requisito de compras com cartão corporativo`, }, roomMembersPage: { memberNotFound: 'Membro não encontrado.', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 32a32348b08a..442bb5339234 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -7296,6 +7296,7 @@ ${reportName} updatedCardFeedStatementPeriod: (feedName: string, newValue?: string, previousValue?: string) => `已更改卡片流水“${feedName}”的账单周期截止日${newValue ? ` 为“${newValue}”` : ''}${previousValue ? ` (先前为“${previousValue}”)` : ''}`, addedReportField: (fieldType: string, fieldName?: string, defaultValue?: string) => `已添加 ${fieldType} 报告字段“${fieldName}”${defaultValue ? ` 默认值为“${defaultValue}”` : ''}`, + updatedRequireCompanyCards: ({enabled}: {enabled: boolean}) => `${enabled ? '已启用' : '已禁用'} 公司商务卡消费要求`, }, roomMembersPage: { memberNotFound: '未找到成员。', diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 4d5baeb786dc..080467dd599b 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -70,6 +70,7 @@ import { getReportActionActorAccountID, getReportActionHtml, getReportActionMessageText, + getRequireCompanyCardsEnabledMessage, getRoomAvatarUpdatedMessage, getRoomChangeLogMessage, getSortedReportActions, @@ -879,6 +880,9 @@ function getLastMessageTextForReport({ if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_PAY_APPROVED_REPORTS_ENABLED)) { lastMessageTextFromReport = getAutoPayApprovedReportsEnabledMessage(translate, lastReportAction); } + if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REQUIRE_COMPANY_CARDS_ENABLED)) { + lastMessageTextFromReport = getRequireCompanyCardsEnabledMessage(translate, lastReportAction); + } if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REIMBURSEMENT)) { lastMessageTextFromReport = getAutoReimbursementMessage(translate, lastReportAction); } diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 5bed9598ed7b..1ea79163a93e 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -3441,6 +3441,12 @@ function getWorkspaceAttendeeTrackingUpdateMessage(translate: LocalizedTranslate return translate('workspaceActions.updatedAttendeeTracking', {enabled: !!enabled}); } +function getRequireCompanyCardsEnabledMessage(translate: LocalizedTranslate, action: ReportAction): string { + const {enabled} = getOriginalMessage(action as ReportAction) ?? {}; + + return translate('workspaceActions.updatedRequireCompanyCards', {enabled: !!enabled}); +} + function getAutoPayApprovedReportsEnabledMessage(translate: LocalizedTranslate, action: ReportAction): string { const {enabled} = getOriginalMessage(action as ReportAction) ?? {}; @@ -4704,6 +4710,7 @@ export { getWorkspaceUpdateFieldMessage, getWorkspaceFeatureEnabledMessage, getWorkspaceAttendeeTrackingUpdateMessage, + getRequireCompanyCardsEnabledMessage, getAutoPayApprovedReportsEnabledMessage, getAutoReimbursementMessage, formatAddressToString, diff --git a/src/libs/ReportNameUtils.ts b/src/libs/ReportNameUtils.ts index 202f1b3758f3..95e48c149cc9 100644 --- a/src/libs/ReportNameUtils.ts +++ b/src/libs/ReportNameUtils.ts @@ -73,6 +73,7 @@ import { getReportAction, getReportActionMessage as getReportActionMessageFromActionsUtils, getReportActionText, + getRequireCompanyCardsEnabledMessage, getSettlementAccountLockedMessage, getSubmitsToUpdateMessage, getTravelUpdateMessage, @@ -773,6 +774,10 @@ function computeReportNameBasedOnReportAction( if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CARD_FEED_STATEMENT_PERIOD)) { return getUpdatedCardFeedStatementPeriodMessage(translate, parentReportAction); } + if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REQUIRE_COMPANY_CARDS_ENABLED)) { + return getRequireCompanyCardsEnabledMessage(translate, parentReportAction); + } + if (isDynamicExternalWorkflowSubmitFailedAction(parentReportAction)) { return getDynamicExternalWorkflowSubmitFailedActionMessage(translate, parentReportAction); } diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 04b2b0eae88f..7130c6c90159 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -82,6 +82,7 @@ import { getReportAction, getReportActionActorAccountID, getReportActionMessageText, + getRequireCompanyCardsEnabledMessage, getRoomAvatarUpdatedMessage, getSetAutoJoinMessage, getSettlementAccountLockedMessage, @@ -1075,6 +1076,8 @@ function getOptionData({ result.alternateText = getWorkspaceFeatureEnabledMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_IS_ATTENDEE_TRACKING_ENABLED) { result.alternateText = getWorkspaceAttendeeTrackingUpdateMessage(translate, lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REQUIRE_COMPANY_CARDS_ENABLED) { + result.alternateText = getRequireCompanyCardsEnabledMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_PAY_APPROVED_REPORTS_ENABLED) { result.alternateText = getAutoPayApprovedReportsEnabledMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REIMBURSEMENT) { diff --git a/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx b/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx index 0ca041558efb..7be8f18e5b6e 100644 --- a/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx @@ -81,6 +81,7 @@ import { getReportAction, getReportActionMessageFragments, getReportActionMessageText, + getRequireCompanyCardsEnabledMessage, getRoomAvatarUpdatedMessage, getSetAutoJoinMessage, getSettlementAccountLockedMessage, @@ -958,6 +959,8 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(getForwardsToUpdateMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_PAY_APPROVED_REPORTS_ENABLED) { Clipboard.setString(getAutoPayApprovedReportsEnabledMessage(translate, reportAction)); + } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REQUIRE_COMPANY_CARDS_ENABLED) { + Clipboard.setString(getRequireCompanyCardsEnabledMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REIMBURSEMENT) { Clipboard.setString(getAutoReimbursementMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_INVOICE_COMPANY_NAME) { diff --git a/src/pages/inbox/report/actionContents/PolicyChangeLogContent.tsx b/src/pages/inbox/report/actionContents/PolicyChangeLogContent.tsx index 45efcc416348..57aa40017315 100644 --- a/src/pages/inbox/report/actionContents/PolicyChangeLogContent.tsx +++ b/src/pages/inbox/report/actionContents/PolicyChangeLogContent.tsx @@ -35,6 +35,7 @@ import { getRemovedCardFeedMessage, getRemovedConnectionMessage, getRenamedCardFeedMessage, + getRequireCompanyCardsEnabledMessage, getSetAutoJoinMessage, getSubmitsToUpdateMessage, getTagListNameUpdatedMessage, @@ -133,6 +134,7 @@ const POLICY_CHANGE_LOG_RESOLVERS: Record = { [CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD]: (translate, action) => getWorkspaceUpdateFieldMessage(translate, action), [CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FEATURE_ENABLED]: (translate, action) => getWorkspaceFeatureEnabledMessage(translate, action), [CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_IS_ATTENDEE_TRACKING_ENABLED]: (translate, action) => getWorkspaceAttendeeTrackingUpdateMessage(translate, action), + [CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REQUIRE_COMPANY_CARDS_ENABLED]: (translate, action) => getRequireCompanyCardsEnabledMessage(translate, action), [CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_APPROVER]: (translate, action) => getDefaultApproverUpdateMessage(translate, action), [CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_SUBMITS_TO]: (translate, action) => getSubmitsToUpdateMessage(translate, action), [CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FORWARDS_TO]: (translate, action) => getForwardsToUpdateMessage(translate, action), diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index ab4d9d4bf4ff..7a8f6c339cb2 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -55,6 +55,7 @@ import { getForeignCurrencyDefaultTaxUpdateMessage, getRemovedCardFeedMessage, getRenamedCardFeedMessage, + getRequireCompanyCardsEnabledMessage, getUnassignedCompanyCardMessage, getUpdatedCardFeedLiabilityMessage, getUpdatedCardFeedStatementPeriodMessage, @@ -4324,6 +4325,28 @@ describe('OptionsListUtils', () => { }); expect(lastMessage).toBe(getForeignCurrencyDefaultTaxUpdateMessage(translateLocal, action)); }); + it('UPDATE_REQUIRE_COMPANY_CARDS_ENABLED action', async () => { + const report: Report = createRandomReport(0, undefined); + const action: ReportAction = { + ...createRandomReportAction(1), + actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REQUIRE_COMPANY_CARDS_ENABLED, + message: [{type: 'COMMENT', text: ''}], + originalMessage: {enabled: true}, + }; + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, { + [action.reportActionID]: action, + }); + const lastMessage = getLastMessageTextForReport({ + translate: translateLocal, + report, + lastActorDetails: null, + policy: undefined, + isReportArchived: false, + + currentUserLogin: CURRENT_USER_EMAIL, + }); + expect(lastMessage).toBe(getRequireCompanyCardsEnabledMessage(translateLocal, action)); + }); it('ADD_CARD_FEED action', async () => { const report: Report = createRandomReport(0, undefined); const action: ReportAction = { diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index bb53b2a8a2d7..d0539cd7749f 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -37,6 +37,7 @@ import { getRemovedCardFeedMessage, getRenamedCardFeedMessage, getReportActionActorAccountID, + getRequireCompanyCardsEnabledMessage, getSendMoneyFlowAction, getSortedReportActions, getSortedReportActionsForDisplay, @@ -4293,6 +4294,38 @@ describe('ReportActionsUtils', () => { }); }); + describe('getRequireCompanyCardsEnabledMessage', () => { + it('should return enabled message when the company card requirement is enabled', () => { + const action = { + actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REQUIRE_COMPANY_CARDS_ENABLED, + reportActionID: '1', + created: '', + originalMessage: { + enabled: true, + }, + message: [], + } as ReportAction; + + const result = getRequireCompanyCardsEnabledMessage(translateLocal, action); + expect(result).toBe('enabled the company card purchases requirement'); + }); + + it('should return disabled message when the company card requirement is disabled', () => { + const action = { + actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REQUIRE_COMPANY_CARDS_ENABLED, + reportActionID: '1', + created: '', + originalMessage: { + enabled: false, + }, + message: [], + } as ReportAction; + + const result = getRequireCompanyCardsEnabledMessage(translateLocal, action); + expect(result).toBe('disabled the company card purchases requirement'); + }); + }); + describe('getAutoReimbursementMessage', () => { it('should return set message when setting limit for the first time from zero', () => { const action = { diff --git a/tests/unit/ReportNameUtilsTest.ts b/tests/unit/ReportNameUtilsTest.ts index ccaa409ff286..9c18e5886707 100644 --- a/tests/unit/ReportNameUtilsTest.ts +++ b/tests/unit/ReportNameUtilsTest.ts @@ -593,6 +593,61 @@ describe('ReportNameUtils', () => { expect(name).toBe('added card feed "Visa Commercial"'); }); + test('UPDATE_REQUIRE_COMPANY_CARDS_ENABLED parent action', () => { + const thread: Report = createWorkspaceThread(150); + const enabledParentAction: ReportAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REQUIRE_COMPANY_CARDS_ENABLED, + reportActionID: String(thread.parentReportActionID), + message: [], + created: '', + lastModified: '', + actorAccountID: 1, + person: [], + originalMessage: { + enabled: true, + }, + } as unknown as ReportAction; + + const parentId = String(thread.parentReportID); + const actionId = String(thread.parentReportActionID); + const reportActionsCollection: Record = { + [`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentId}`]: {[actionId]: enabledParentAction}, + }; + + const enabledName = computeReportName( + thread, + emptyCollections.reports, + emptyCollections.policies, + undefined, + undefined, + participantsPersonalDetails, + reportActionsCollection, + currentUserAccountID, + ); + expect(enabledName).toBe('enabled the company card purchases requirement'); + + const disabledParentAction: ReportAction = { + ...enabledParentAction, + originalMessage: { + enabled: false, + }, + } as unknown as ReportAction; + const disabledReportActionsCollection: Record = { + [`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentId}`]: {[actionId]: disabledParentAction}, + }; + const disabledName = computeReportName( + thread, + emptyCollections.reports, + emptyCollections.policies, + undefined, + undefined, + participantsPersonalDetails, + disabledReportActionsCollection, + currentUserAccountID, + ); + expect(disabledName).toBe('disabled the company card purchases requirement'); + }); + test('DELETE_CARD_FEED parent action', () => { const thread: Report = createWorkspaceThread(101); const parentAction: ReportAction = { diff --git a/tests/unit/SidebarUtilsTest.ts b/tests/unit/SidebarUtilsTest.ts index 943d16e16fa4..5d35405fd867 100644 --- a/tests/unit/SidebarUtilsTest.ts +++ b/tests/unit/SidebarUtilsTest.ts @@ -1873,6 +1873,79 @@ describe('SidebarUtils', () => { expect(result?.alternateText).toBe('changed the foreign currency default tax rate to "Foreign Tax (10%)" (previously "Foreign Tax (15%)")'); }); + it('returns the correct alternate text for UPDATE_REQUIRE_COMPANY_CARDS_ENABLED action', async () => { + const report: Report = { + ...createRandomReport(4, 'policyAdmins'), + participants: {'18921695': {notificationPreference: 'always'}}, + }; + const enabledAction: ReportAction = { + ...createRandomReportAction(2), + actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REQUIRE_COMPANY_CARDS_ENABLED, + originalMessage: {enabled: true}, + }; + const enabledReportActions: ReportActions = {[enabledAction.reportActionID]: enabledAction}; + await act(async () => { + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report); + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, enabledReportActions); + }); + + const enabledResult = SidebarUtils.getOptionData({ + report, + reportAttributes: undefined, + reportNameValuePairs: {}, + personalDetails: {}, + policy: undefined, + invoiceReceiverPolicy: undefined, + parentReportAction: undefined, + conciergeReportID: '', + oneTransactionThreadReport: undefined, + card: undefined, + translate: translateLocal, + localeCompare, + lastAction: enabledAction, + lastActionReport: undefined, + isReportArchived: undefined, + currentUserAccountID: 0, + currentUserLogin: CURRENT_USER_LOGIN, + reportAttributesDerived: undefined, + }); + + expect(enabledResult?.alternateText).toBe('enabled the company card purchases requirement'); + + const disabledAction: ReportAction = { + ...createRandomReportAction(3), + actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REQUIRE_COMPANY_CARDS_ENABLED, + originalMessage: {enabled: false}, + }; + const disabledReportActions: ReportActions = {[disabledAction.reportActionID]: disabledAction}; + await act(async () => { + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, disabledReportActions); + }); + + const disabledResult = SidebarUtils.getOptionData({ + report, + reportAttributes: undefined, + reportNameValuePairs: {}, + personalDetails: {}, + policy: undefined, + invoiceReceiverPolicy: undefined, + parentReportAction: undefined, + conciergeReportID: '', + oneTransactionThreadReport: undefined, + card: undefined, + translate: translateLocal, + localeCompare, + lastAction: disabledAction, + lastActionReport: undefined, + isReportArchived: undefined, + currentUserAccountID: 0, + currentUserLogin: CURRENT_USER_LOGIN, + reportAttributesDerived: undefined, + }); + + expect(disabledResult?.alternateText).toBe('disabled the company card purchases requirement'); + }); + it('returns the correct alternate text for ADD_CARD_FEED action', async () => { const report: Report = { ...createRandomReport(4, 'policyAdmins'),