@@ -7,6 +7,7 @@ import ScreenWrapper from '@components/ScreenWrapper';
77import useLocalize from '@hooks/useLocalize' ;
88import useOnyx from '@hooks/useOnyx' ;
99import usePermissions from '@hooks/usePermissions' ;
10+ import BankAccount from '@libs/models/BankAccount' ;
1011import Navigation from '@libs/Navigation/Navigation' ;
1112import { goBackFromInvalidPolicy } from '@libs/PolicyUtils' ;
1213import mapCurrencyToCountry from '@pages/ReimbursementAccount/utils/mapCurrencyToCountry' ;
@@ -32,7 +33,7 @@ function WorkspaceOverviewCurrencyPage({policy}: WorkspaceOverviewCurrencyPagePr
3233 const { translate} = useLocalize ( ) ;
3334 const { isBetaEnabled} = usePermissions ( ) ;
3435 const [ isForcedToChangeCurrency ] = useOnyx ( ONYXKEYS . IS_FORCED_TO_CHANGE_CURRENCY , { canBeMissing : true } ) ;
35-
36+ const [ hasVBA = false ] = useOnyx ( ONYXKEYS . REIMBURSEMENT_ACCOUNT , { selector : ( value ) => value ?. achData ?. state === BankAccount . STATE . OPEN , canBeMissing : true } ) ;
3637 const onSelectCurrency = ( item : CurrencyListItem ) => {
3738 if ( ! policy ) {
3839 return ;
@@ -46,7 +47,7 @@ function WorkspaceOverviewCurrencyPage({policy}: WorkspaceOverviewCurrencyPagePr
4647 setIsForcedToChangeCurrency ( false ) ;
4748
4849 if ( isCurrencySupportedForGlobalReimbursement ( item . currencyCode as CurrencyType , isBetaEnabled ( CONST . BETAS . GLOBAL_REIMBURSEMENTS_ON_ND ) ?? false ) ) {
49- navigateToBankAccountRoute ( policy . id , ROUTES . WORKSPACE_WORKFLOWS . getRoute ( policy . id ) ) ;
50+ navigateToBankAccountRoute ( policy . id , ROUTES . WORKSPACE_WORKFLOWS . getRoute ( policy . id ) , { forceReplace : true } ) ;
5051 return ;
5152 }
5253 }
@@ -57,7 +58,11 @@ function WorkspaceOverviewCurrencyPage({policy}: WorkspaceOverviewCurrencyPagePr
5758 < AccessOrNotFoundWrapper
5859 policyID = { policy ?. id }
5960 accessVariants = { [ CONST . POLICY . ACCESS_VARIANTS . ADMIN ] }
60- fullPageNotFoundViewProps = { { onLinkPress : goBackFromInvalidPolicy , subtitleKey : isEmptyObject ( policy ) ? undefined : 'workspace.common.notAuthorized' } }
61+ shouldBeBlocked = { hasVBA }
62+ fullPageNotFoundViewProps = { {
63+ onLinkPress : hasVBA ? ( ) => Navigation . goBack ( ) : goBackFromInvalidPolicy ,
64+ subtitleKey : hasVBA || isEmptyObject ( policy ) ? undefined : 'workspace.common.notAuthorized' ,
65+ } }
6166 >
6267 < ScreenWrapper
6368 enableEdgeToEdgeBottomSafeAreaPadding
0 commit comments