Skip to content

Commit fc6cbfa

Browse files
MelvinBothoangzinh
andcommitted
Update code comment to explain why || is used instead of ??
Co-authored-by: Vinh Hoang <hoangzinh@users.noreply.github.com>
1 parent f5ca285 commit fc6cbfa

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/libs/TransactionUtils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,6 +2144,7 @@ function getTaxName(policy: OnyxEntry<Policy>, transaction: OnyxEntry<Transactio
21442144
// Only fall back to the default tax code when tax tracking is enabled on the policy.
21452145
// When taxes are disabled and the user deletes a tax, taxCode becomes undefined (the API returns null, which Onyx strips).
21462146
// Without this check, getTaxName would fall back to defaultTaxCode and display the default tax rate instead of showing empty.
2147+
// We use || instead of ?? because taxCode may be an empty string, which should also trigger the fallback.
21472148
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
21482149
const effectiveTaxCode = transaction?.taxCode || (policy?.tax?.trackingEnabled ? defaultTaxCode : undefined);
21492150
const taxRate = effectiveTaxCode ? Object.values(transformedTaxRates(policy, transaction)).find((rate) => rate.code === effectiveTaxCode) : undefined;

0 commit comments

Comments
 (0)