From 4909ef9e02644a2e52c721b70167d20893022e55 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Nov 2026 09:17:38 -0500 Subject: [PATCH 1/9] add non default vendors --- src/CONST/index.ts | 1 + src/hooks/useViolations.ts | 1 + src/languages/en.ts | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index c8b0e5c582c5..522972d0fffa 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -8173,6 +8173,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/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/en.ts b/src/languages/en.ts index 8b3b2b8fe64b..b834af38d716 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -12452,6 +12452,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': @@ -12705,6 +12706,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', From c8a53948d319034c43945ff37e08a58a6049364c Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Nov 2026 09:49:44 -0500 Subject: [PATCH 2/9] update modifi8ed expense message --- src/libs/ModifiedExpenseMessage.ts | 11 ++++++++--- src/types/onyx/OriginalMessage.ts | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 3f5f7668bf19..1949f4b9d7b9 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -196,10 +196,10 @@ 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. + * 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']); +const RULES_MODIFIED_FIELDS_WITH_LABELS = new Set(['amount', 'category', 'comment', 'description', 'merchant', 'tag', 'tax', 'vendor']); function getRulesModifiedMessage( translate: LocalizedTranslate, @@ -241,6 +241,11 @@ function getRulesModifiedMessage( if (key === 'tag') { return translate('iou.rulesModifiedFields.common', key, getCommaSeparatedTagNameWithSanitizedColons(value ?? ''), isFirst); } + if (key === 'vendor') { + const vendorEntry = modifiedFields[key]; + return translate('iou.rulesModifiedFields.common', key, vendorEntry?.name || vendorEntry?.externalID || '', 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); diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index df276ea1aca0..a9e153754c1e 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -1164,6 +1164,15 @@ type PolicyRulesModifiedFields = { // eslint-disable-next-line @typescript-eslint/naming-convention field_id_TAX: PolicyRuleTaxRate; }; + + /** The vendor the rule set */ + vendor?: { + /** 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 +1198,15 @@ type PersonalRulesModifiedFields = { field_id_TAX: PolicyRuleTaxRate; }; + /** The vendor the rule set */ + vendor?: { + /** 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; + }; + reportName?: string; }; From 97b4558a8ec66c3e9bcbacdadd766cf2fbc99b4a Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Nov 2026 10:35:55 -0500 Subject: [PATCH 3/9] add translations --- src/languages/de.ts | 2 ++ src/languages/el.ts | 2 ++ src/languages/es.ts | 2 ++ src/languages/fr.ts | 2 ++ src/languages/it.ts | 2 ++ src/languages/ja.ts | 2 ++ src/languages/nl.ts | 2 ++ src/languages/pl.ts | 2 ++ src/languages/pt-BR.ts | 2 ++ src/languages/zh-hans.ts | 2 ++ 10 files changed, 20 insertions(+) diff --git a/src/languages/de.ts b/src/languages/de.ts index 9abdd8394ccb..c1eb7baa3aa5 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -12329,6 +12329,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', @@ -12372,6 +12373,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 eaf43f2c2b5e..cf2c798e518d 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -12538,6 +12538,7 @@ ${reportName}`, nonDefaultReimbursable: 'Μη προεπιλεγμένη ρυθμίση επιστρεφόμενων εξόδων', nonDefaultTag: 'Μη προεπιλεγμένη ετικέτα', nonDefaultTax: 'Μη προεπιλεγμένος φόρος', + nonDefaultVendor: 'Προμηθευτής εκτός προεπιλογής', }, ruleViolation: { fallback: 'Παραβιάζει την πολιτική εξόδων', @@ -12581,6 +12582,7 @@ ${reportName}`, nonDefaultReimbursable: 'Η δυνατότητα αποζημίωσης διαφέρει από την προεπιλογή του χώρου εργασίας', nonDefaultTag: 'Η ετικέτα διαφέρει από την προεπιλογή του χώρου εργασίας', nonDefaultTax: 'Ο φόρος διαφέρει από την προεπιλογή του χώρου εργασίας', + nonDefaultVendor: 'Ο προμηθευτής διαφέρει από την προεπιλογή του χώρου εργασίας', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName: string) => `Απαιτείται το πεδίο ${fieldName}`, diff --git a/src/languages/es.ts b/src/languages/es.ts index 0b8ed195f0ad..c36bdc9339a6 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -12593,6 +12593,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', @@ -12636,6 +12637,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 b6215f26216c..98640ae0627b 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -12358,6 +12358,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', @@ -12401,6 +12402,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 36d547221b0f..6231ff604431 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -12275,6 +12275,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', @@ -12318,6 +12319,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 e80f018a17ef..27145a393c34 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -12076,6 +12076,7 @@ ${reportName}`, nonDefaultReimbursable: 'デフォルト以外の立替精算設定', nonDefaultTag: 'デフォルト以外のタグ', nonDefaultTax: '既定以外の税金', + nonDefaultVendor: '非デフォルトの仕入先', }, ruleViolation: { fallback: '経費ポリシー違反', @@ -12119,6 +12120,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 ca921e8c4f95..b3ca3a131d44 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -12245,6 +12245,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', @@ -12288,6 +12289,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 593e9ffdb062..f7338b406169 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -12287,6 +12287,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', @@ -12330,6 +12331,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 6b6bef0c69c7..9c29d5f67643 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -12247,6 +12247,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', @@ -12290,6 +12291,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 2f6b42d77061..b820c11d2b70 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -11770,6 +11770,7 @@ ${reportName}`, nonDefaultReimbursable: '非默认报销设置', nonDefaultTag: '非默认标签', nonDefaultTax: '非默认税率', + nonDefaultVendor: '非默认供应商', }, ruleViolation: { fallback: '违反报销政策', @@ -11813,6 +11814,7 @@ ${reportName}`, nonDefaultReimbursable: '报销设置不同于工作区默认值', nonDefaultTag: '标签与工作区默认值不同', nonDefaultTax: '税率与工作区默认值不同', + nonDefaultVendor: '供应商与工作区默认设置不一致', }, reportViolations: { [CONST.REPORT_VIOLATIONS.FIELD_REQUIRED]: (fieldName: string) => `${fieldName} 为必填项`, From 066ff664fdac5e8d577139c54412b51fca08616c Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Nov 2026 10:43:20 -0500 Subject: [PATCH 4/9] support vendors in modified expense message --- src/languages/TranslationTypes.ts | 4 ++++ src/libs/ModifiedExpenseMessage.ts | 18 +++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/languages/TranslationTypes.ts b/src/languages/TranslationTypes.ts index 86ef117709ae..87d4f4467ebe 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/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 1949f4b9d7b9..42de8a829c52 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -234,24 +234,24 @@ function getRulesModifiedMessage( return translate('iou.rulesModifiedFields.tax', taxRateName, isFirst); } - const value = modifiedFields[key]; + if (key === 'vendor') { + const vendorEntry = modifiedFields[key]; + const vendorName = vendorEntry ? vendorEntry.name || vendorEntry.externalID : ''; + return translate('iou.rulesModifiedFields.common', key, vendorName, 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); - } - if (key === 'vendor') { - const vendorEntry = modifiedFields[key]; - return translate('iou.rulesModifiedFields.common', key, vendorEntry?.name || vendorEntry?.externalID || '', 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]; From 19d126d7d8b32c4e3114c5d6be453dababc8b7cd Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Fri, 20 Nov 2026 11:55:09 -0500 Subject: [PATCH 5/9] always use the name, since auth guarentees it --- src/libs/ModifiedExpenseMessage.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 42de8a829c52..dd1721935124 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -235,9 +235,7 @@ function getRulesModifiedMessage( } if (key === 'vendor') { - const vendorEntry = modifiedFields[key]; - const vendorName = vendorEntry ? vendorEntry.name || vendorEntry.externalID : ''; - return translate('iou.rulesModifiedFields.common', key, vendorName, isFirst); + return translate('iou.rulesModifiedFields.common', key, modifiedFields[key]?.name ?? '', isFirst); } if (key === 'category') { return translate('iou.rulesModifiedFields.common', key, getDecodedCategoryName(modifiedFields[key] ?? ''), isFirst); From e29e721f057714b8144dc07677b90844d8468509 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Wed, 25 Nov 2026 13:01:13 -0500 Subject: [PATCH 6/9] cleanup naming --- src/libs/ModifiedExpenseMessage.ts | 43 +++++++++++++++--------------- src/types/onyx/OriginalMessage.ts | 24 ++++++++--------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index dd1721935124..8d86c4560436 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'; @@ -195,6 +196,17 @@ function getMovedFromOrToReportMessage( } } +/** + * Resolves the display name of a vendor from any connection that has it, then the name saved on the action, then the externalID, + * so the message still identifies the vendor rather than rendering an empty name. + */ +function resolveVendorName(policy: OnyxEntry, entry: RulesModifiedVendor | null | undefined): string { + if (!entry?.externalID) { + return ''; + } + return findVendorByID(policy, entry.externalID)?.name || entry.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. @@ -205,6 +217,7 @@ function getRulesModifiedMessage( translate: LocalizedTranslate, fields: PolicyRulesModifiedFields | PersonalRulesModifiedFields, isPersonalRules: boolean, + policy: OnyxEntry, policyID?: string, hasPolicyRuleAccess?: boolean, ) { @@ -235,7 +248,7 @@ function getRulesModifiedMessage( } if (key === 'vendor') { - return translate('iou.rulesModifiedFields.common', key, modifiedFields[key]?.name ?? '', isFirst); + return translate('iou.rulesModifiedFields.common', key, lodashEscape(resolveVendorName(policy, modifiedFields[key])), isFirst); } if (key === 'category') { return translate('iou.rulesModifiedFields.common', key, getDecodedCategoryName(modifiedFields[key] ?? ''), isFirst); @@ -513,23 +526,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), + resolveVendorName(policy, reportActionOriginalMessage?.vendor), + resolveVendorName(policy, reportActionOriginalMessage?.oldVendor), translate('common.vendor'), true, setFragments, @@ -548,7 +548,7 @@ function getForReportAction({ if (hasPersonalRulesModifiedFields) { const personalRulesModifiedFields = reportActionOriginalMessage.personalRulesModifiedFields; if (personalRulesModifiedFields) { - return getRulesModifiedMessage(translate, personalRulesModifiedFields, true); + return getRulesModifiedMessage(translate, personalRulesModifiedFields, true, policy); } } @@ -556,9 +556,10 @@ 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); + return getRulesModifiedMessage(translate, policyRulesModifiedFields, false, policy, policy?.id ?? reportActionOriginalMessage.policyID, hasPolicyRuleAccess); } } diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index a9e153754c1e..4a2193ed3ae4 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -1166,13 +1166,16 @@ type PolicyRulesModifiedFields = { }; /** The vendor the rule set */ - vendor?: { - /** The ID of the vendor in the accounting integration */ - externalID: string; + vendor?: RulesModifiedVendor; +}; - /** The display name of the vendor, empty when it is no longer in the integration's vendor list */ - name?: string; - }; +/** 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 */ @@ -1199,13 +1202,7 @@ type PersonalRulesModifiedFields = { }; /** The vendor the rule set */ - vendor?: { - /** 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; - }; + vendor?: RulesModifiedVendor; reportName?: string; }; @@ -1996,6 +1993,7 @@ type OriginalMessage = T extends keyof OriginalMessa export default OriginalMessage; export type { + RulesModifiedVendor, DecisionName, OriginalMessageIOU, OriginalMessageReportPreview, From 78a9627db4099e1b8d9f207c6f4d48c805889586 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Thu, 26 Nov 2026 10:36:03 -0500 Subject: [PATCH 7/9] prioritize the name --- src/libs/ModifiedExpenseMessage.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 8d86c4560436..1b90498a6e93 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -197,14 +197,13 @@ function getMovedFromOrToReportMessage( } /** - * Resolves the display name of a vendor from any connection that has it, then the name saved on the action, then the externalID, - * so the message still identifies the vendor rather than rendering an empty name. + * Resolves the display name of a vendor */ function resolveVendorName(policy: OnyxEntry, entry: RulesModifiedVendor | null | undefined): string { if (!entry?.externalID) { return ''; } - return findVendorByID(policy, entry.externalID)?.name || entry.name || entry.externalID; + return entry.name || findVendorByID(policy, entry.externalID)?.name || entry.externalID; } /** From 4abcaa74c79214a961495cc45d80dc71999d7493 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Thu, 26 Nov 2026 13:04:17 -0500 Subject: [PATCH 8/9] fix formatting --- src/libs/ModifiedExpenseMessage.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 1b90498a6e93..ed7b242f3811 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -527,8 +527,8 @@ function getForReportAction({ if (hasModifiedVendor) { buildMessageFragmentForValue( translate, - resolveVendorName(policy, reportActionOriginalMessage?.vendor), - resolveVendorName(policy, reportActionOriginalMessage?.oldVendor), + lodashEscape(resolveVendorName(policy, reportActionOriginalMessage?.vendor)), + lodashEscape(resolveVendorName(policy, reportActionOriginalMessage?.oldVendor)), translate('common.vendor'), true, setFragments, @@ -558,7 +558,11 @@ function getForReportAction({ 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); - return getRulesModifiedMessage(translate, policyRulesModifiedFields, false, policy, policy?.id ?? reportActionOriginalMessage.policyID, hasPolicyRuleAccess); + 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; + } } } From db7792756508540ed6d3381d75389cbab83da444 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Thu, 26 Nov 2026 15:45:38 -0500 Subject: [PATCH 9/9] add tests and hide vendor row --- .../ReportActionItem/MoneyRequestView.tsx | 8 ++++- tests/unit/ModifiedExpenseMessageTest.ts | 32 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 588ea0c87c03..caddffe5de3d 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -874,7 +874,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/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);