From 1685e56690317791b3e0719b4c6715a3cbe1a63f Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 6 Jun 2024 15:10:26 -0600 Subject: [PATCH] fix crash --- src/libs/DistanceRequestUtils.ts | 4 ++-- src/libs/actions/Policy/Policy.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/DistanceRequestUtils.ts b/src/libs/DistanceRequestUtils.ts index ed4a6a73c9b9..cbae1e0d3bfb 100644 --- a/src/libs/DistanceRequestUtils.ts +++ b/src/libs/DistanceRequestUtils.ts @@ -52,7 +52,7 @@ function getMileageRates(policy: OnyxEntry, includeDisabledRates = false } Object.entries(distanceUnit.rates).forEach(([rateID, rate]) => { - if (!includeDisabledRates && !rate.enabled) { + if (!includeDisabledRates && rate.enabled === false) { return; } @@ -89,7 +89,7 @@ function getDefaultMileageRate(policy: OnyxEntry | EmptyObject): Mileage } const mileageRates = getMileageRates(policy); - const distanceRate = Object.values(mileageRates).find((rate) => rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE) ?? Object.values(mileageRates)[0]; + const distanceRate = Object.values(mileageRates).find((rate) => rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE) ?? Object.values(mileageRates)[0] ?? {}; return { customUnitRateID: distanceRate.customUnitRateID, diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index e17d4290a46a..0e168f973078 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -1407,6 +1407,7 @@ function buildOptimisticCustomUnits(): OptimisticCustomUnits { customUnitRateID, name: CONST.CUSTOM_UNITS.DEFAULT_RATE, rate: CONST.CUSTOM_UNITS.MILEAGE_IRS_RATE * CONST.POLICY.CUSTOM_UNIT_RATE_BASE_OFFSET, + enabled: true, currency, }, },