From ade39e1956abc32c3ea94de6433d38e8229366d1 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 7 Jun 2024 14:08:52 -0600 Subject: [PATCH 1/3] fix crash --- .../workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx index 70b829d41159..a0a4d4624d63 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx @@ -51,7 +51,7 @@ function PolicyDistanceRateDetailsPage({policy, route}: PolicyDistanceRateDetail const taxRateExternalID = rate.attributes?.taxRateExternalID; const isDistanceTrackTaxEnabled = !!customUnit?.attributes?.taxEnabled; - const taxRate = taxRateExternalID ? `${policy?.taxRates?.taxes[taxRateExternalID].name} (${policy?.taxRates?.taxes[taxRateExternalID].value})` : ''; + const taxRate = taxRateExternalID ? `${policy?.taxRates?.taxes[taxRateExternalID]?.name} (${policy?.taxRates?.taxes[taxRateExternalID]?.value})` : ''; // Rates can be disabled or deleted as long as in the remaining rates there is always at least one enabled rate and there are no pending delete action const canDisableOrDeleteRate = Object.values(customUnit?.rates ?? {}).some( (distanceRate: Rate) => distanceRate?.enabled && rateID !== distanceRate?.customUnitRateID && distanceRate?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, From 3007f898b56df45c0f958aa6d3769c096b3dbd8c Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 7 Jun 2024 14:13:53 -0600 Subject: [PATCH 2/3] handle online case --- .../workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx index a0a4d4624d63..9f9a7b29f028 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx @@ -51,7 +51,7 @@ function PolicyDistanceRateDetailsPage({policy, route}: PolicyDistanceRateDetail const taxRateExternalID = rate.attributes?.taxRateExternalID; const isDistanceTrackTaxEnabled = !!customUnit?.attributes?.taxEnabled; - const taxRate = taxRateExternalID ? `${policy?.taxRates?.taxes[taxRateExternalID]?.name} (${policy?.taxRates?.taxes[taxRateExternalID]?.value})` : ''; + const taxRate = taxRateExternalID && policy?.taxRates?.taxes[taxRateExternalID] ? `${policy?.taxRates?.taxes[taxRateExternalID]?.name} (${policy?.taxRates?.taxes[taxRateExternalID]?.value})` : ''; // Rates can be disabled or deleted as long as in the remaining rates there is always at least one enabled rate and there are no pending delete action const canDisableOrDeleteRate = Object.values(customUnit?.rates ?? {}).some( (distanceRate: Rate) => distanceRate?.enabled && rateID !== distanceRate?.customUnitRateID && distanceRate?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, From a5cd5451afa3f9cfdc005e3d740ad52ceff7178f Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 7 Jun 2024 14:22:30 -0600 Subject: [PATCH 3/3] fix lint --- .../workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx index 9f9a7b29f028..00204d1e40c7 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx @@ -51,7 +51,8 @@ function PolicyDistanceRateDetailsPage({policy, route}: PolicyDistanceRateDetail const taxRateExternalID = rate.attributes?.taxRateExternalID; const isDistanceTrackTaxEnabled = !!customUnit?.attributes?.taxEnabled; - const taxRate = taxRateExternalID && policy?.taxRates?.taxes[taxRateExternalID] ? `${policy?.taxRates?.taxes[taxRateExternalID]?.name} (${policy?.taxRates?.taxes[taxRateExternalID]?.value})` : ''; + const taxRate = + taxRateExternalID && policy?.taxRates?.taxes[taxRateExternalID] ? `${policy?.taxRates?.taxes[taxRateExternalID]?.name} (${policy?.taxRates?.taxes[taxRateExternalID]?.value})` : ''; // Rates can be disabled or deleted as long as in the remaining rates there is always at least one enabled rate and there are no pending delete action const canDisableOrDeleteRate = Object.values(customUnit?.rates ?? {}).some( (distanceRate: Rate) => distanceRate?.enabled && rateID !== distanceRate?.customUnitRateID && distanceRate?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,