From 0bbe02165173314ecbec85347f3ecc2477716c44 Mon Sep 17 00:00:00 2001 From: dominictb Date: Thu, 20 Jun 2024 11:50:40 +0700 Subject: [PATCH] fix: always enable the default first rate entry --- src/libs/actions/Policy/DistanceRate.ts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/libs/actions/Policy/DistanceRate.ts b/src/libs/actions/Policy/DistanceRate.ts index af92de5d2a1b..c10e4d87484c 100644 --- a/src/libs/actions/Policy/DistanceRate.ts +++ b/src/libs/actions/Policy/DistanceRate.ts @@ -133,16 +133,7 @@ function enablePolicyDistanceRates(policyID: string, enabled: boolean) { const rateEntries = Object.entries(customUnit?.rates ?? {}); // find the rate to be enabled after disabling the distance rate feature - // first check the default rate - let rateEntryToBeEnabled = rateEntries.find((rate) => rate[1]?.name === 'Default Rate'); - // if the default rate is not enabled/doesn't exist, we'll switch to the first enabled rate - if (!rateEntryToBeEnabled?.[1] || !rateEntryToBeEnabled[1].enabled) { - rateEntryToBeEnabled = rateEntries.find((rate) => !!rate[1]?.enabled); - } - // if no rate is enabled, we'll switch to the first rate - if (!rateEntryToBeEnabled?.[1]) { - rateEntryToBeEnabled = rateEntries[0]; - } + const rateEntryToBeEnabled = rateEntries[0]; onyxData.optimisticData?.push({ onyxMethod: Onyx.METHOD.MERGE,