diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 65cff5baf54a..76376bba7eef 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3170,13 +3170,13 @@ function updateMoneyRequestDistanceRate( policy: OnyxEntry, policyTagList: OnyxEntry, policyCategories: OnyxEntry, - taxAmount?: number, - taxCode?: string, + updatedTaxAmount?: number, + updatedTaxCode?: string, ) { const transactionChanges: TransactionChanges = { customUnitRateID: rateID, - ...(taxAmount ? {taxAmount} : {}), - ...(taxCode ? {taxCode} : {}), + ...(typeof updatedTaxAmount === 'number' ? {taxAmount: updatedTaxAmount} : {}), + ...(updatedTaxCode ? {taxCode: updatedTaxCode} : {}), }; const allReports = ReportConnection.getAllReports(); const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null; @@ -3188,7 +3188,9 @@ function updateMoneyRequestDistanceRate( data = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTagList, policyCategories, true); } const {params, onyxData} = data; - API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DISTANCE_RATE, params, onyxData); + // `taxAmount` & `taxCode` only needs to be updated in the optimistic data, so we need to remove them from the params + const {taxAmount, taxCode, ...paramsWithoutTaxUpdated} = params; + API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DISTANCE_RATE, paramsWithoutTaxUpdated, onyxData); } /** Edits an existing distance expense */