diff --git a/src/CONST/index.ts b/src/CONST/index.ts index dd3305f61c06..56ba5dfca5a0 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -8283,6 +8283,7 @@ const CONST = { NONDEFAULT_REIMBURSABLE: 'nonDefaultReimbursable', NONDEFAULT_TAG: 'nonDefaultTag', NONDEFAULT_TAX: 'nonDefaultTax', + NONDEFAULT_VENDOR: 'nonDefaultVendor', MODIFIED_AMOUNT: 'modifiedAmount', MODIFIED_DATE: 'modifiedDate', INCREASED_DISTANCE: 'increasedDistance', diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 701a24cd3b54..0d26383d4745 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -876,7 +876,13 @@ function MoneyRequestView({ } const violations = getViolationsForField(field, data, policyHasDependentTags, tagValue); - const displayableViolations = field === 'merchant' ? violations.filter((violation) => violation.name === CONST.VIOLATIONS.NONDEFAULT_MERCHANT) : violations; + let displayableViolations = violations; + if (field === 'merchant') { + displayableViolations = violations.filter((violation) => violation.name === CONST.VIOLATIONS.NONDEFAULT_MERCHANT); + } else if (field === 'vendor' && !shouldShowVendor) { + // The vendor violations must follow the same gate as the Vendor field, or they would warn about a field that is hidden. + displayableViolations = []; + } if (displayableViolations.length > 0) { return `${displayableViolations diff --git a/src/hooks/useViolations.ts b/src/hooks/useViolations.ts index a97878f012df..6d02eeefa037 100644 --- a/src/hooks/useViolations.ts +++ b/src/hooks/useViolations.ts @@ -59,6 +59,7 @@ const violationNameToField: Record 'reimbursable', nonDefaultTag: () => 'tag', nonDefaultTax: () => 'tax', + nonDefaultVendor: () => 'vendor', modifiedAmount: () => 'amount', modifiedDate: () => 'date', increasedDistance: () => 'waypoints', diff --git a/src/languages/TranslationTypes.ts b/src/languages/TranslationTypes.ts index 6d3169fa29e6..8077854db861 100644 --- a/src/languages/TranslationTypes.ts +++ b/src/languages/TranslationTypes.ts @@ -68,6 +68,10 @@ type PolicyRulesModifiedFields = { // eslint-disable-next-line @typescript-eslint/naming-convention field_id_TAX: PolicyRuleTaxRate; }; + vendor?: { + externalID: string; + name?: string; + }; }; type PersonalRulesModifiedFields = PolicyRulesModifiedFields & { diff --git a/src/languages/de.ts b/src/languages/de.ts index 4022e15b178c..7b568996ae25 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -12586,6 +12586,7 @@ Fügen Sie weitere Ausgabelimits hinzu, um den Cashflow Ihres Unternehmens zu sc nonDefaultReimbursable: 'Nicht standardmäßige erstattungsfähige Einstellung', nonDefaultTag: 'Nicht-Standard-Tag', nonDefaultTax: 'Nicht-Standardsteuer', + nonDefaultVendor: 'Nicht-Standardlieferant', }, ruleViolation: { fallback: 'Verstößt gegen Spesenrichtlinie', @@ -12629,6 +12630,7 @@ Fügen Sie weitere Ausgabelimits hinzu, um den Cashflow Ihres Unternehmens zu sc nonDefaultReimbursable: 'Erstattungsfähig weicht von der Standardarbeitsbereichseinstellung ab', nonDefaultTag: 'Tag weicht von der Arbeitsbereichs-Standardeinstellung ab', nonDefaultTax: 'Steuer unterscheidet sich von der Arbeitsbereichs-Standardeinstellung', + nonDefaultVendor: 'Anbieter unterscheidet sich von der Arbeitsbereichs-Vorgabe', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName: string) => `${fieldName} ist erforderlich`, diff --git a/src/languages/el.ts b/src/languages/el.ts index 1be7979e186b..72ff7c69e5a1 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -12793,6 +12793,7 @@ ${reportName}`, nonDefaultReimbursable: 'Μη προεπιλεγμένη ρυθμίση επιστρεφόμενων εξόδων', nonDefaultTag: 'Μη προεπιλεγμένη ετικέτα', nonDefaultTax: 'Μη προεπιλεγμένος φόρος', + nonDefaultVendor: 'Προμηθευτής εκτός προεπιλογής', }, ruleViolation: { fallback: 'Παραβιάζει την πολιτική εξόδων', @@ -12836,6 +12837,7 @@ ${reportName}`, nonDefaultReimbursable: 'Η δυνατότητα αποζημίωσης διαφέρει από την προεπιλογή του χώρου εργασίας', nonDefaultTag: 'Η ετικέτα διαφέρει από την προεπιλογή του χώρου εργασίας', nonDefaultTax: 'Ο φόρος διαφέρει από την προεπιλογή του χώρου εργασίας', + nonDefaultVendor: 'Ο προμηθευτής διαφέρει από την προεπιλογή του χώρου εργασίας', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName: string) => `Απαιτείται το πεδίο ${fieldName}`, diff --git a/src/languages/en.ts b/src/languages/en.ts index 1236828a59a1..337097ee16ba 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -12720,6 +12720,7 @@ const translations = { nonDefaultReimbursable: 'Reimbursable differs from workspace default', nonDefaultTag: 'Tag differs from workspace default', nonDefaultTax: 'Tax differs from workspace default', + nonDefaultVendor: 'Vendor differs from workspace default', modifiedAmount: (type?: ViolationDataType, displayPercentVariance?: number) => { switch (type) { case 'distance': @@ -12973,6 +12974,7 @@ const translations = { nonDefaultReimbursable: 'Non-default reimbursable setting', nonDefaultTag: 'Non-default tag', nonDefaultTax: 'Non-default tax', + nonDefaultVendor: 'Non-default vendor', nonExpensiworksExpense: 'Non-Expensiworks expense', overAutoApprovalLimit: 'Over auto-approval limit', overCategoryLimit: 'Over category limit', diff --git a/src/languages/es.ts b/src/languages/es.ts index cfa10f7103da..6e672b7e0157 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -12848,6 +12848,7 @@ ${reportName}`, nonDefaultReimbursable: 'Configuración reembolsable no predeterminada', nonDefaultTag: 'Etiqueta no predeterminada', nonDefaultTax: 'Impuesto no predeterminado', + nonDefaultVendor: 'Proveedor no predeterminado', }, ruleViolation: { fallback: 'Infringe la política de gastos', @@ -12891,6 +12892,7 @@ ${reportName}`, nonDefaultReimbursable: 'Reembolsable difiere del valor predeterminado del espacio de trabajo', nonDefaultTag: 'La etiqueta difiere del valor predeterminado del espacio de trabajo', nonDefaultTax: 'El impuesto difiere del valor predeterminado del espacio de trabajo', + nonDefaultVendor: 'El proveedor es distinto del proveedor predeterminado del espacio de trabajo', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName) => `${fieldName} es obligatorio`, diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 0469c2d930b4..7bfb356846c1 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -12614,6 +12614,7 @@ Ajoutez davantage de règles de dépenses pour protéger la trésorerie de l’e nonDefaultReimbursable: 'Paramètre de remboursement non par défaut', nonDefaultTag: 'Tag non par défaut', nonDefaultTax: 'Taxe non par défaut', + nonDefaultVendor: 'Fournisseur non par défaut', }, ruleViolation: { fallback: 'Viole la politique de dépenses', @@ -12657,6 +12658,7 @@ Ajoutez davantage de règles de dépenses pour protéger la trésorerie de l’e nonDefaultReimbursable: 'Différente du paramètre par défaut de l’espace de travail pour les remboursements', nonDefaultTag: 'Le tag diffère du paramètre par défaut de l’espace de travail', nonDefaultTax: 'Taxe différente de celle de l’espace de travail par défaut', + nonDefaultVendor: 'Le fournisseur diffère de celui de l’espace de travail par défaut', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName: string) => `${fieldName} est obligatoire`, diff --git a/src/languages/it.ts b/src/languages/it.ts index 145f18f4f08f..0db40f9e32df 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -12531,6 +12531,7 @@ Aggiungi altre regole di spesa per proteggere il flusso di cassa aziendale.`, nonDefaultReimbursable: 'Impostazione rimborsabile non predefinita', nonDefaultTag: 'Tag non predefinito', nonDefaultTax: 'Imposta non predefinita', + nonDefaultVendor: 'Fornitore non predefinito', }, ruleViolation: { fallback: 'Viola la politica spese', @@ -12574,6 +12575,7 @@ Aggiungi altre regole di spesa per proteggere il flusso di cassa aziendale.`, nonDefaultReimbursable: 'Rimborsabile diverso dall’impostazione predefinita dello spazio di lavoro', nonDefaultTag: "L'etichetta è diversa da quella predefinita dello spazio di lavoro", nonDefaultTax: 'Imposta diversa da quella predefinita dello spazio di lavoro', + nonDefaultVendor: 'Il fornitore è diverso da quello predefinito dello spazio di lavoro', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName: string) => `${fieldName} è obbligatorio`, diff --git a/src/languages/ja.ts b/src/languages/ja.ts index fe8308d46f2f..a7c4ca5b9083 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -12328,6 +12328,7 @@ ${reportName}`, nonDefaultReimbursable: 'デフォルト以外の立替精算設定', nonDefaultTag: 'デフォルト以外のタグ', nonDefaultTax: '既定以外の税金', + nonDefaultVendor: '非デフォルトの仕入先', }, ruleViolation: { fallback: '経費ポリシー違反', @@ -12371,6 +12372,7 @@ ${reportName}`, nonDefaultReimbursable: '精算可がワークスペースのデフォルトと異なります', nonDefaultTag: 'タグがワークスペースのデフォルトと異なります', nonDefaultTax: '税がワークスペースのデフォルトと異なります', + nonDefaultVendor: 'ベンダーがワークスペースのデフォルトと異なります', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName: string) => `${fieldName} は必須です`, diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 8ae91bc18db5..95cacc0dbab6 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -12498,6 +12498,7 @@ er bestedingsregels toe om de kasstroom van het bedrijf te beschermen.`, nonDefaultReimbursable: 'Niet-standaard terugbetaalbare instelling', nonDefaultTag: 'Tag buiten de standaard', nonDefaultTax: 'Niet-standaardbelasting', + nonDefaultVendor: 'Niet-standaard leverancier', }, ruleViolation: { fallback: 'Schendt onkostenbeleid', @@ -12541,6 +12542,7 @@ er bestedingsregels toe om de kasstroom van het bedrijf te beschermen.`, nonDefaultReimbursable: 'Vergoedbaar wijkt af van de standaardinstelling van de workspace', nonDefaultTag: 'Label wijkt af van werkruimte-standaard', nonDefaultTax: 'Belasting wijkt af van werkruimte-standaard', + nonDefaultVendor: 'Leverancier wijkt af van standaardinstelling van de workspace', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName: string) => `${fieldName} is verplicht`, diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 6c731a0fc179..4cbfb841408b 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -12541,6 +12541,7 @@ Dodaj więcej zasad wydatków, żeby chronić płynność finansową firmy.`, nonDefaultReimbursable: 'Niedomyslne ustawienie zwrotu kosztów', nonDefaultTag: 'Tag inny niż domyślny', nonDefaultTax: 'Podatek niestandardowy', + nonDefaultVendor: 'Dostawca inny niż domyślny', }, ruleViolation: { fallback: 'Narusza politykę wydatków', @@ -12584,6 +12585,7 @@ Dodaj więcej zasad wydatków, żeby chronić płynność finansową firmy.`, nonDefaultReimbursable: 'Do zwrotu, różni się od domyślnego ustawienia w przestrzeni roboczej', nonDefaultTag: 'Tag różni się od domyślnego ustawienia przestrzeni roboczej', nonDefaultTax: 'Podatek różni się od domyślnego ustawienia w przestrzeni roboczej', + nonDefaultVendor: 'Dostawca różni się od domyślnego w przestrzeni roboczej', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName: string) => `Pole ${fieldName} jest wymagane`, diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 26de2c1c27fa..192845a5dc3e 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -12502,6 +12502,7 @@ Adicione mais regras de gasto para proteger o fluxo de caixa da empresa.`, nonDefaultReimbursable: 'Configuração reembolsável não padrão', nonDefaultTag: 'Tag não padrão', nonDefaultTax: 'Imposto não padrão', + nonDefaultVendor: 'Fornecedor não padrão', }, ruleViolation: { fallback: 'Viola a política de despesas', @@ -12545,6 +12546,7 @@ Adicione mais regras de gasto para proteger o fluxo de caixa da empresa.`, nonDefaultReimbursable: 'Reembolsável difere do padrão do espaço de trabalho', nonDefaultTag: 'A tag é diferente da padrão do espaço de trabalho', nonDefaultTax: 'Imposto diferente do padrão do espaço de trabalho', + nonDefaultVendor: 'Fornecedor diferente do padrão do workspace', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName: string) => `${fieldName} é obrigatório`, diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 2ef7c6710e7c..ff0c0921498a 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -12014,6 +12014,7 @@ ${reportName}`, nonDefaultReimbursable: '非默认报销设置', nonDefaultTag: '非默认标签', nonDefaultTax: '非默认税率', + nonDefaultVendor: '非默认供应商', }, ruleViolation: { fallback: '违反报销政策', @@ -12057,6 +12058,7 @@ ${reportName}`, nonDefaultReimbursable: '报销设置不同于工作区默认值', nonDefaultTag: '标签与工作区默认值不同', nonDefaultTax: '税率与工作区默认值不同', + nonDefaultVendor: '供应商与工作区默认设置不一致', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName: string) => `${fieldName} 为必填项`, diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 3f5f7668bf19..ed7b242f3811 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -5,12 +5,13 @@ import type {CurrencyListActionsContextType} from '@hooks/useCurrencyList'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {Policy, PolicyCategories, PolicyTagLists, Report, ReportAction} from '@src/types/onyx'; -import type {PersonalRulesModifiedFields, PolicyRulesModifiedFields} from '@src/types/onyx/OriginalMessage'; +import type {PersonalRulesModifiedFields, PolicyRulesModifiedFields, RulesModifiedVendor} from '@src/types/onyx/OriginalMessage'; import ObjectUtils from '@src/types/utils/ObjectUtils'; import type {OnyxEntry} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; +import lodashEscape from 'lodash/escape'; import isEmpty from 'lodash/isEmpty'; import {getDecodedCategoryName, isCategoryMissing} from './CategoryUtils'; @@ -196,15 +197,26 @@ function getMovedFromOrToReportMessage( } /** - * The fields a rules modified message can name. A rule can set more than these, the vendor for one, and the backend - * sends back whatever it applied, so a field with no label here is left out rather than rendered without one. + * Resolves the display name of a vendor */ -const RULES_MODIFIED_FIELDS_WITH_LABELS = new Set(['amount', 'category', 'comment', 'description', 'merchant', 'tag', 'tax']); +function resolveVendorName(policy: OnyxEntry, entry: RulesModifiedVendor | null | undefined): string { + if (!entry?.externalID) { + return ''; + } + return entry.name || findVendorByID(policy, entry.externalID)?.name || entry.externalID; +} + +/** + * The fields a rules modified message can name. The backend sends back whatever a rule applied, so a field with + * no label here is left out rather than rendered without one. + */ +const RULES_MODIFIED_FIELDS_WITH_LABELS = new Set(['amount', 'category', 'comment', 'description', 'merchant', 'tag', 'tax', 'vendor']); function getRulesModifiedMessage( translate: LocalizedTranslate, fields: PolicyRulesModifiedFields | PersonalRulesModifiedFields, isPersonalRules: boolean, + policy: OnyxEntry, policyID?: string, hasPolicyRuleAccess?: boolean, ) { @@ -234,19 +246,22 @@ function getRulesModifiedMessage( return translate('iou.rulesModifiedFields.tax', taxRateName, isFirst); } - const value = modifiedFields[key]; + if (key === 'vendor') { + return translate('iou.rulesModifiedFields.common', key, lodashEscape(resolveVendorName(policy, modifiedFields[key])), isFirst); + } if (key === 'category') { - return translate('iou.rulesModifiedFields.common', key, getDecodedCategoryName(value ?? ''), isFirst); + return translate('iou.rulesModifiedFields.common', key, getDecodedCategoryName(modifiedFields[key] ?? ''), isFirst); } if (key === 'tag') { - return translate('iou.rulesModifiedFields.common', key, getCommaSeparatedTagNameWithSanitizedColons(value ?? ''), isFirst); + return translate('iou.rulesModifiedFields.common', key, getCommaSeparatedTagNameWithSanitizedColons(modifiedFields[key] ?? ''), isFirst); } + // The backend saves description as comment, so display it with the description label. if (key === 'comment') { - return translate('iou.rulesModifiedFields.common', 'description', String(value), isFirst); + return translate('iou.rulesModifiedFields.common', 'description', String(modifiedFields[key]), isFirst); } - return translate('iou.rulesModifiedFields.common', key, String(value), isFirst); + return translate('iou.rulesModifiedFields.common', key, String(modifiedFields[key]), isFirst); }); const fragments = [...standaloneFragments, ...listFragment]; @@ -510,23 +525,10 @@ function getForReportAction({ // fallback. const hasModifiedVendor = isReportActionOriginalMessageAnObject && ('oldVendor' in reportActionOriginalMessage || 'vendor' in reportActionOriginalMessage); if (hasModifiedVendor) { - // Vendor is stored on the action as `{externalID, name?, wasManuallySet}` (or absent/null). - // Resolve the display name from any connection that has the vendor data (QBO, Intacct, or - // Xero), without gating on the workspace's current export mode — a past "set vendor" action - // should still render the vendor name after an admin switches the non-reimbursable export - // type. When no connection has the vendor any more, prefer the display name persisted on the - // action, then fall back to the externalID so the fragment still identifies which vendor was - // set rather than rendering `set vendor ""`. - const resolveVendorName = (entry: typeof reportActionOriginalMessage.vendor): string => { - if (!entry?.externalID) { - return ''; - } - return findVendorByID(policy, entry.externalID)?.name ?? entry.name ?? entry.externalID; - }; buildMessageFragmentForValue( translate, - resolveVendorName(reportActionOriginalMessage?.vendor), - resolveVendorName(reportActionOriginalMessage?.oldVendor), + lodashEscape(resolveVendorName(policy, reportActionOriginalMessage?.vendor)), + lodashEscape(resolveVendorName(policy, reportActionOriginalMessage?.oldVendor)), translate('common.vendor'), true, setFragments, @@ -545,7 +547,7 @@ function getForReportAction({ if (hasPersonalRulesModifiedFields) { const personalRulesModifiedFields = reportActionOriginalMessage.personalRulesModifiedFields; if (personalRulesModifiedFields) { - return getRulesModifiedMessage(translate, personalRulesModifiedFields, true); + return getRulesModifiedMessage(translate, personalRulesModifiedFields, true, policy); } } @@ -553,9 +555,14 @@ function getForReportAction({ if (hasPolicyRulesModifiedFields) { const policyRulesModifiedFields = reportActionOriginalMessage.policyRulesModifiedFields; - if (policyRulesModifiedFields && policy?.id) { - const hasPolicyRuleAccess = arePolicyRulesEnabled(policy, policyCategories) && isPolicyAdmin(policy, currentUserLogin); - return getRulesModifiedMessage(translate, policyRulesModifiedFields, false, policy?.id, hasPolicyRuleAccess); + if (policyRulesModifiedFields) { + // Until the workspace loads, access can't be checked, so hasPolicyRuleAccess stays false and the message links to the help page. + const hasPolicyRuleAccess = !!policy?.id && arePolicyRulesEnabled(policy, policyCategories) && isPolicyAdmin(policy, currentUserLogin); + const policyRulesMessage = getRulesModifiedMessage(translate, policyRulesModifiedFields, false, policy, policy?.id ?? reportActionOriginalMessage.policyID, hasPolicyRuleAccess); + // With nothing to format, fall through to the generic "changed the expense" message. + if (policyRulesMessage) { + return policyRulesMessage; + } } } diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index c5faf577a839..3b047e138e81 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -1164,6 +1164,18 @@ type PolicyRulesModifiedFields = { // eslint-disable-next-line @typescript-eslint/naming-convention field_id_TAX: PolicyRuleTaxRate; }; + + /** The vendor the rule set */ + vendor?: RulesModifiedVendor; +}; + +/** A vendor written by a rule */ +type RulesModifiedVendor = { + /** The ID of the vendor in the accounting integration */ + externalID: string; + + /** The display name of the vendor, empty when it is no longer in the integration's vendor list */ + name?: string; }; /** Personal rules modified fields. Each member holds the new value the rule wrote, not the current one */ @@ -1189,6 +1201,9 @@ type PersonalRulesModifiedFields = { field_id_TAX: PolicyRuleTaxRate; }; + /** The vendor the rule set */ + vendor?: RulesModifiedVendor; + reportName?: string; }; @@ -1996,6 +2011,7 @@ type OriginalMessage = T extends keyof OriginalMessa export default OriginalMessage; export type { + RulesModifiedVendor, DecisionName, OriginalMessageIOU, OriginalMessageReportPreview, diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index c099f2ef6308..704c5f582979 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -1966,6 +1966,38 @@ describe('ModifiedExpenseMessage', () => { expect(result).toEqual(expectedResult); }); + it('shows the full vendor name and the help link when a rule sets a vendor before the workspace loads', () => { + // Given a non-admin viewer, no loaded policy, and a rule that set a vendor whose name has angle brackets + jest.mocked(isPolicyAdmin).mockReturnValue(false); + const reportAction = { + ...createRandomReportAction(1), + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, + originalMessage: { + policyID: policyRulesPolicyId, + policyRulesModifiedFields: { + vendor: {externalID: 'v-acme-west', name: 'Acme '}, + }, + } as OriginalMessageModifiedExpense, + }; + + // When the message is built without a policy + const result = getForReportAction({ + convertToDisplayString, + translate: translateLocal, + reportAction, + policy: undefined, + policyTags: undefined, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserLogin: CURRENT_USER_LOGIN, + formatPhoneNumber, + movedFromReportName: undefined, + }); + + // Then the persisted full name is shown (escaped) and the link goes to the help page + expect(result).toContain('set the vendor to "Acme <West>"'); + expect(result).toContain(CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL); + }); + it('returns the correct text message with help link for non-admin', () => { jest.mocked(isPolicyAdmin).mockReturnValue(false);