From d8254a6c5d53378f051b88a3aaf41c13858a2a98 Mon Sep 17 00:00:00 2001 From: "Antony M. Kithinzi" Date: Tue, 26 Nov 2024 22:09:41 +0800 Subject: [PATCH] fix: Getting the correct policy output currency in WorkspaceProfilePage.tsx and WorkspaceProfileCurrencyPage.tsx --- src/pages/workspace/WorkspaceProfileCurrencyPage.tsx | 5 ++++- src/pages/workspace/WorkspaceProfilePage.tsx | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx b/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx index c14f4ea51eab..ed9adb7be11a 100644 --- a/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx +++ b/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx @@ -4,6 +4,7 @@ import type {CurrencyListItem} from '@components/CurrencySelectionList/types'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import useLocalize from '@hooks/useLocalize'; +import DistanceRequestUtils from '@libs/DistanceRequestUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as PolicyUtils from '@libs/PolicyUtils'; import mapCurrencyToCountry from '@pages/ReimbursementAccount/utils/mapCurrencyToCountry'; @@ -30,6 +31,8 @@ function WorkspaceProfileCurrencyPage({policy}: WorkspaceProfileCurrencyPageProp Navigation.setNavigationActionToMicrotaskQueue(Navigation.goBack); }; + const outputCurrency = policy?.outputCurrency ?? DistanceRequestUtils.getDefaultMileageRate(policy)?.currency ?? PolicyUtils.getPersonalPolicy()?.outputCurrency; + return ( diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index 482d66846e66..756da0f644b0 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -20,6 +20,7 @@ import usePermissions from '@hooks/usePermissions'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeIllustrations from '@hooks/useThemeIllustrations'; import useThemeStyles from '@hooks/useThemeStyles'; +import DistanceRequestUtils from '@libs/DistanceRequestUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {FullScreenNavigatorParamList} from '@libs/Navigation/types'; @@ -53,7 +54,7 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, route}: Workspac // When we create a new workspace, the policy prop will be empty on the first render. Therefore, we have to use policyDraft until policy has been set in Onyx. const policy = policyDraft?.id ? policyDraft : policyProp; - const outputCurrency = policy?.outputCurrency ?? ''; + const outputCurrency = policy?.outputCurrency ?? DistanceRequestUtils.getDefaultMileageRate(policy)?.currency ?? PolicyUtils.getPersonalPolicy()?.outputCurrency ?? ''; const currencySymbol = currencyList?.[outputCurrency]?.symbol ?? ''; const formattedCurrency = !isEmptyObject(policy) && !isEmptyObject(currencyList) ? `${outputCurrency} - ${currencySymbol}` : '';