@@ -63,13 +63,13 @@ const buildQBOWithVendorBillExportPolicy = (vendors: Array<{id: string; name: st
6363 } ) ;
6464
6565/** Xero policy whose supplier list scopes vendor matching to Xero (label flips vendor -> supplier). */
66- const buildXeroPolicy = ( contacts : Record < string , { id : string ; name : string ; email : string } > ) : Policy =>
66+ const buildXeroPolicy = ( contacts : Record < string , { id : string ; name : string ; email : string } > | undefined ) : Policy =>
6767 createMock < Policy > ( {
6868 ...createRandomPolicy ( 0 ) ,
6969 connections : createMock < Connections > ( {
7070 [ CONST . POLICY . CONNECTIONS . NAME . XERO ] : {
7171 config : { isConfigured : true } ,
72- data : { contacts} ,
72+ data : contacts === undefined ? { } : { contacts} ,
7373 } ,
7474 } ) ,
7575 } ) ;
@@ -147,12 +147,13 @@ describe('Vendor matching on merchant rules', () => {
147147 expect ( buildTableData ( policy ) . at ( 0 ) ?. ruleDescription ) . toContain ( 'Update vendor to "Vendor unavailable"' ) ;
148148 } ) ;
149149
150- it ( 'renders "Vendor unavailable" instead of the raw external ID when no connection knows the vendor' , ( ) => {
151- // No active matching list and no connection (active or stale) resolves the vendorID — e.g. the accounting
152- // connection was disconnected, so its vendor data is gone from Onyx. The summary must surface the
153- // "unavailable" copy rather than leaking the raw external ID. (A vendorID that a connection still knows
154- // continues to render its name — see the export-mode-switch case, which exercises the same tier-3 branch.)
150+ it ( 'preserves the raw external ID while the active vendor list is not hydrated' , ( ) => {
155151 const policy = withCodingRules ( buildQBOPolicy ( undefined ) , { rule1 : buildVendorRule ( 'v-1' ) } ) ;
152+ expect ( buildTableData ( policy ) . at ( 0 ) ?. ruleDescription ) . toContain ( 'Update vendor to "v-1"' ) ;
153+ } ) ;
154+
155+ it ( 'renders "Vendor unavailable" when no matching integration remains' , ( ) => {
156+ const policy = withCodingRules ( createRandomPolicy ( 0 ) , { rule1 : buildVendorRule ( 'v-1' ) } ) ;
156157 const description = buildTableData ( policy ) . at ( 0 ) ?. ruleDescription ;
157158 expect ( description ) . toContain ( 'Update vendor to "Vendor unavailable"' ) ;
158159 expect ( description ) . not . toContain ( '"v-1"' ) ;
@@ -185,6 +186,9 @@ describe('Vendor matching on merchant rules', () => {
185186
186187 const missing = withCodingRules ( buildXeroPolicy ( { } ) , { rule1 : buildVendorRule ( 'xc1' ) } ) ;
187188 expect ( buildTableData ( missing ) . at ( 0 ) ?. ruleDescription ) . toContain ( 'Update supplier to "Supplier unavailable"' ) ;
189+
190+ const unhydrated = withCodingRules ( buildXeroPolicy ( undefined ) , { rule1 : buildVendorRule ( 'xc1' ) } ) ;
191+ expect ( buildTableData ( unhydrated ) . at ( 0 ) ?. ruleDescription ) . toContain ( 'Update supplier to "xc1"' ) ;
188192 } ) ;
189193 } ) ;
190194
@@ -213,8 +217,12 @@ describe('Vendor matching on merchant rules', () => {
213217 expect ( describeRule ( buildQBOPolicy ( [ ] ) , 'v-1' ) ) . toContain ( 'Update vendor to "Vendor unavailable"' ) ;
214218 } ) ;
215219
216- it ( 'renders "Vendor unavailable" instead of the raw external ID when no connection knows the vendor' , ( ) => {
217- const description = describeRule ( buildQBOPolicy ( undefined ) , 'v-1' ) ;
220+ it ( 'preserves the raw external ID while the active vendor list is not hydrated' , ( ) => {
221+ expect ( describeRule ( buildQBOPolicy ( undefined ) , 'v-1' ) ) . toContain ( 'Update vendor to "v-1"' ) ;
222+ } ) ;
223+
224+ it ( 'renders "Vendor unavailable" when no matching integration remains' , ( ) => {
225+ const description = describeRule ( createRandomPolicy ( 0 ) , 'v-1' ) ;
218226 expect ( description ) . toContain ( 'Update vendor to "Vendor unavailable"' ) ;
219227 expect ( description ) . not . toContain ( '"v-1"' ) ;
220228 } ) ;
@@ -237,6 +245,9 @@ describe('Vendor matching on merchant rules', () => {
237245
238246 const missing = buildXeroPolicy ( { } ) ;
239247 expect ( describeRule ( missing , 'xc1' ) ) . toContain ( 'Update supplier to "Supplier unavailable"' ) ;
248+
249+ const unhydrated = buildXeroPolicy ( undefined ) ;
250+ expect ( describeRule ( unhydrated , 'xc1' ) ) . toContain ( 'Update supplier to "xc1"' ) ;
240251 } ) ;
241252 } ) ;
242253
0 commit comments