From 1cc462510b10fe670d8c1f02a7a5180be30dada6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Musia=C5=82?= Date: Thu, 27 Nov 2025 10:29:48 +0100 Subject: [PATCH 1/4] fix browser back buttone reopenes the same page --- .../VerifiedBankAccountFlowEntryPoint.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx b/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx index aa4041267792..f5112f79b22e 100644 --- a/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx +++ b/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx @@ -153,7 +153,7 @@ function VerifiedBankAccountFlowEntryPoint({ const handleConnectManually = () => { if (!isAccountValidated) { setReimbursementAccountOptionPressed(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL); - Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo)); + Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo), {forceReplace: true}); return; } @@ -173,7 +173,7 @@ function VerifiedBankAccountFlowEntryPoint({ if (!isAccountValidated) { setReimbursementAccountOptionPressed(CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID); - Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo)); + Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo), {forceReplace: true}); return; } From f2a28fb89cc2257408cddb9de4689770c8c099c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Musia=C5=82?= Date: Thu, 27 Nov 2025 12:28:09 +0100 Subject: [PATCH 2/4] change approach --- .../ReimbursementAccountVerifyAccountPage.tsx | 5 ++++- .../VerifiedBankAccountFlowEntryPoint.tsx | 4 ++-- src/pages/settings/VerifyAccountPageBase.tsx | 15 ++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountVerifyAccountPage.tsx b/src/pages/ReimbursementAccount/ReimbursementAccountVerifyAccountPage.tsx index a76d1e203ffd..0a8644c94bc4 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountVerifyAccountPage.tsx +++ b/src/pages/ReimbursementAccount/ReimbursementAccountVerifyAccountPage.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; import VerifyAccountPageBase from '@pages/settings/VerifyAccountPageBase'; @@ -13,7 +14,9 @@ function ReimbursementAccountVerifyAccountPage({route}: ReimbursementAccountVeri return ( { + Navigation.goBack(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute(policyID, '', backTo, CONST.BANK_ACCOUNT.STEP.COUNTRY), {compareParams: false}); + }} /> ); } diff --git a/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx b/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx index f5112f79b22e..aa4041267792 100644 --- a/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx +++ b/src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx @@ -153,7 +153,7 @@ function VerifiedBankAccountFlowEntryPoint({ const handleConnectManually = () => { if (!isAccountValidated) { setReimbursementAccountOptionPressed(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL); - Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo), {forceReplace: true}); + Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo)); return; } @@ -173,7 +173,7 @@ function VerifiedBankAccountFlowEntryPoint({ if (!isAccountValidated) { setReimbursementAccountOptionPressed(CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID); - Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo), {forceReplace: true}); + Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo)); return; } diff --git a/src/pages/settings/VerifyAccountPageBase.tsx b/src/pages/settings/VerifyAccountPageBase.tsx index 71042d27cca4..5485dae32cd8 100644 --- a/src/pages/settings/VerifyAccountPageBase.tsx +++ b/src/pages/settings/VerifyAccountPageBase.tsx @@ -13,12 +13,12 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; -type VerifyAccountPageBaseProps = {navigateBackTo?: Route; navigateForwardTo?: Route}; +type VerifyAccountPageBaseProps = {navigateBackTo?: Route; navigateForwardTo?: Route; handleClose?: () => void}; /** * This is a base page as RHP for account verification. The back & forward url logic should be handled on per case basis in higher component. */ -function VerifyAccountPageBase({navigateBackTo, navigateForwardTo}: VerifyAccountPageBaseProps) { +function VerifyAccountPageBase({navigateBackTo, navigateForwardTo, handleClose}: VerifyAccountPageBaseProps) { const styles = useThemeStyles(); const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true}); @@ -40,7 +40,7 @@ function VerifyAccountPageBase({navigateBackTo, navigateForwardTo}: VerifyAccoun [loginList, contactMethod, formatPhoneNumber], ); - const handleClose = useCallback(() => { + const handleCloseFallback = useCallback(() => { Navigation.goBack(navigateBackTo); }, [navigateBackTo]); @@ -49,13 +49,14 @@ function VerifyAccountPageBase({navigateBackTo, navigateForwardTo}: VerifyAccoun if (!isUserValidated) { return; } - if (navigateForwardTo) { Navigation.navigate(navigateForwardTo, {forceReplace: true}); - } else { + } else if (handleClose) { handleClose(); + } else { + handleCloseFallback(); } - }, [isUserValidated, navigateForwardTo, handleClose]); + }, [isUserValidated, navigateForwardTo, handleCloseFallback, handleClose]); // Once user is validated or the modal is dismissed, we don't want to show empty content. if (isUserValidated) { @@ -84,7 +85,7 @@ function VerifyAccountPageBase({navigateBackTo, navigateForwardTo}: VerifyAccoun handleSubmitForm={handleSubmitForm} validateError={!isEmptyObject(validateLoginError) ? validateLoginError : getLatestErrorField(loginData, 'validateCodeSent')} clearError={() => clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')} - onClose={handleClose} + onClose={handleCloseFallback} /> ); } From adfa90844ea2df01a4520495e2b8c983b93e8f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Musia=C5=82?= Date: Thu, 27 Nov 2025 12:31:01 +0100 Subject: [PATCH 3/4] small refactor --- src/pages/settings/VerifyAccountPageBase.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/pages/settings/VerifyAccountPageBase.tsx b/src/pages/settings/VerifyAccountPageBase.tsx index 5485dae32cd8..ea07548113c5 100644 --- a/src/pages/settings/VerifyAccountPageBase.tsx +++ b/src/pages/settings/VerifyAccountPageBase.tsx @@ -40,7 +40,10 @@ function VerifyAccountPageBase({navigateBackTo, navigateForwardTo, handleClose}: [loginList, contactMethod, formatPhoneNumber], ); - const handleCloseFallback = useCallback(() => { + const handleCloseWithFallback = useCallback(() => { + if (handleClose) { + handleClose(); + } Navigation.goBack(navigateBackTo); }, [navigateBackTo]); @@ -51,12 +54,10 @@ function VerifyAccountPageBase({navigateBackTo, navigateForwardTo, handleClose}: } if (navigateForwardTo) { Navigation.navigate(navigateForwardTo, {forceReplace: true}); - } else if (handleClose) { - handleClose(); } else { - handleCloseFallback(); + handleCloseWithFallback(); } - }, [isUserValidated, navigateForwardTo, handleCloseFallback, handleClose]); + }, [isUserValidated, navigateForwardTo, handleCloseWithFallback, handleClose]); // Once user is validated or the modal is dismissed, we don't want to show empty content. if (isUserValidated) { @@ -67,7 +68,7 @@ function VerifyAccountPageBase({navigateBackTo, navigateForwardTo, handleClose}: > @@ -85,7 +86,7 @@ function VerifyAccountPageBase({navigateBackTo, navigateForwardTo, handleClose}: handleSubmitForm={handleSubmitForm} validateError={!isEmptyObject(validateLoginError) ? validateLoginError : getLatestErrorField(loginData, 'validateCodeSent')} clearError={() => clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')} - onClose={handleCloseFallback} + onClose={handleCloseWithFallback} /> ); } From 5ed063d07525f701a868046b4c9aa9dde3193188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Musia=C5=82?= Date: Thu, 27 Nov 2025 12:32:14 +0100 Subject: [PATCH 4/4] add a return --- src/pages/settings/VerifyAccountPageBase.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/settings/VerifyAccountPageBase.tsx b/src/pages/settings/VerifyAccountPageBase.tsx index ea07548113c5..53adf4766abf 100644 --- a/src/pages/settings/VerifyAccountPageBase.tsx +++ b/src/pages/settings/VerifyAccountPageBase.tsx @@ -43,9 +43,10 @@ function VerifyAccountPageBase({navigateBackTo, navigateForwardTo, handleClose}: const handleCloseWithFallback = useCallback(() => { if (handleClose) { handleClose(); + return; } Navigation.goBack(navigateBackTo); - }, [navigateBackTo]); + }, [handleClose, navigateBackTo]); // Handle navigation once the user is validated useEffect(() => {