Skip to content

Commit

Permalink
Merge pull request #53132 from Tony-MK/fix/52190
Browse files Browse the repository at this point in the history
fix: Getting the correct policy output currency in WorkspaceProfilePa…
  • Loading branch information
mjasikowski authored Nov 27, 2024
2 parents c62ab78 + d8254a6 commit 4c30302
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/pages/workspace/WorkspaceProfileCurrencyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -30,6 +31,8 @@ function WorkspaceProfileCurrencyPage({policy}: WorkspaceProfileCurrencyPageProp
Navigation.setNavigationActionToMicrotaskQueue(Navigation.goBack);
};

const outputCurrency = policy?.outputCurrency ?? DistanceRequestUtils.getDefaultMileageRate(policy)?.currency ?? PolicyUtils.getPersonalPolicy()?.outputCurrency;

return (
<AccessOrNotFoundWrapper
policyID={policy?.id ?? '-1'}
Expand All @@ -48,7 +51,7 @@ function WorkspaceProfileCurrencyPage({policy}: WorkspaceProfileCurrencyPageProp
<CurrencySelectionList
searchInputLabel={translate('workspace.editor.currencyInputLabel')}
onSelect={onSelectCurrency}
initiallySelectedCurrencyCode={policy?.outputCurrency}
initiallySelectedCurrencyCode={outputCurrency}
/>
</ScreenWrapper>
</AccessOrNotFoundWrapper>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/workspace/WorkspaceProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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}` : '';

Expand Down

0 comments on commit 4c30302

Please sign in to comment.