From d96de1fa5576559418fc998988c5a049d22ce844 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 19 Sep 2024 20:29:58 +0530 Subject: [PATCH 1/4] fix: Distance rates - Change Rate to default leads to app crash. Signed-off-by: krishna2323 --- src/libs/actions/IOU.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 65cff5baf54a..94ea4ec81123 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3159,7 +3159,9 @@ function updateMoneyRequestDescription( data = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTagList, policyCategories, true); } const {params, onyxData} = data; - API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DESCRIPTION, params, onyxData); + // `taxAmount` & `taxCode` only needs to be updated in the optimistic data, so we need to remove them from the params object + const {taxAmount, taxCode, ...paramsWithoutTaxUpdated} = params; + API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DESCRIPTION, paramsWithoutTaxUpdated, onyxData); } /** Updates the distance rate of an expense */ From 533bba7b59dc48794b2d2a71bc6f25f869c86e3d Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 19 Sep 2024 20:56:26 +0530 Subject: [PATCH 2/4] minor update. Signed-off-by: krishna2323 --- src/libs/actions/IOU.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 94ea4ec81123..a16355cc478b 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3159,9 +3159,8 @@ function updateMoneyRequestDescription( data = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTagList, policyCategories, true); } const {params, onyxData} = data; - // `taxAmount` & `taxCode` only needs to be updated in the optimistic data, so we need to remove them from the params object - const {taxAmount, taxCode, ...paramsWithoutTaxUpdated} = params; - API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DESCRIPTION, paramsWithoutTaxUpdated, onyxData); + + API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DESCRIPTION, params, onyxData); } /** Updates the distance rate of an expense */ @@ -3172,13 +3171,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} : {}), + ...(updatedTaxAmount ? {taxAmount: updatedTaxAmount} : {}), + ...(updatedTaxCode ? {taxCode: updatedTaxCode} : {}), }; const allReports = ReportConnection.getAllReports(); const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null; @@ -3190,7 +3189,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 */ From 67e28f5f6ec03e7ca3cda78497b80a94ec14385f Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 19 Sep 2024 21:26:27 +0530 Subject: [PATCH 3/4] minor fix. Signed-off-by: krishna2323 --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index a16355cc478b..ad1b08b101e8 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3176,7 +3176,7 @@ function updateMoneyRequestDistanceRate( ) { const transactionChanges: TransactionChanges = { customUnitRateID: rateID, - ...(updatedTaxAmount ? {taxAmount: updatedTaxAmount} : {}), + ...(typeof updatedTaxAmount === 'number' ? {taxAmount: updatedTaxAmount} : {}), ...(updatedTaxCode ? {taxCode: updatedTaxCode} : {}), }; const allReports = ReportConnection.getAllReports(); From ce02d0e11d54a974945f001014fa9fa41b50abc4 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 19 Sep 2024 21:32:42 +0530 Subject: [PATCH 4/4] remove extra space. Signed-off-by: krishna2323 --- src/libs/actions/IOU.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index ad1b08b101e8..76376bba7eef 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3159,7 +3159,6 @@ function updateMoneyRequestDescription( data = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTagList, policyCategories, true); } const {params, onyxData} = data; - API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DESCRIPTION, params, onyxData); }