@@ -486,14 +486,17 @@ function renamePolicyTax(policyID: string, taxID: string, newName: string) {
486486function setPolicyTaxCode ( policyID : string , oldTaxCode : string , newTaxCode : string ) {
487487 const policy = allPolicies ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` ] ;
488488 const originalTaxRate = { ...policy ?. taxRates ?. taxes [ oldTaxCode ] } ;
489+ const oldDefaultExternalID = policy ?. taxRates ?. defaultExternalID ;
490+ const oldForeignTaxDefault = policy ?. taxRates ?. foreignTaxDefault ;
489491 const onyxData : OnyxData = {
490492 optimisticData : [
491493 {
492494 onyxMethod : Onyx . METHOD . MERGE ,
493495 key : `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` ,
494496 value : {
495497 taxRates : {
496- defaultExternalID : oldTaxCode === policy ?. taxRates ?. defaultExternalID ? newTaxCode : policy ?. taxRates ?. defaultExternalID ,
498+ defaultExternalID : oldTaxCode === oldDefaultExternalID ? newTaxCode : oldDefaultExternalID ,
499+ foreignTaxDefault : oldTaxCode === oldForeignTaxDefault ? newTaxCode : oldForeignTaxDefault ,
497500 taxes : {
498501 [ oldTaxCode ] : null ,
499502 [ newTaxCode ] : {
@@ -514,7 +517,8 @@ function setPolicyTaxCode(policyID: string, oldTaxCode: string, newTaxCode: stri
514517 key : `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` ,
515518 value : {
516519 taxRates : {
517- defaultExternalID : oldTaxCode === policy ?. taxRates ?. defaultExternalID ? newTaxCode : policy ?. taxRates ?. defaultExternalID ,
520+ defaultExternalID : oldTaxCode === oldDefaultExternalID ? newTaxCode : oldDefaultExternalID ,
521+ foreignTaxDefault : oldTaxCode === oldForeignTaxDefault ? newTaxCode : oldForeignTaxDefault ,
518522 taxes : {
519523 [ oldTaxCode ] : null ,
520524 [ newTaxCode ] : {
@@ -535,7 +539,8 @@ function setPolicyTaxCode(policyID: string, oldTaxCode: string, newTaxCode: stri
535539 key : `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` ,
536540 value : {
537541 taxRates : {
538- defaultExternalID : policy ?. taxRates ?. defaultExternalID ,
542+ defaultExternalID : oldDefaultExternalID ,
543+ foreignTaxDefault : oldForeignTaxDefault ,
539544 taxes : {
540545 [ newTaxCode ] : null ,
541546 [ oldTaxCode ] : {
0 commit comments