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 a44a989ac91a..08aa0254ddc7 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -2000,6 +2000,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, }, },