diff --git a/src/components/BlockingViews/FullPageNotFoundView.js b/src/components/BlockingViews/FullPageNotFoundView.js index 54bdc015de37..a9c4bf63b65e 100644 --- a/src/components/BlockingViews/FullPageNotFoundView.js +++ b/src/components/BlockingViews/FullPageNotFoundView.js @@ -8,6 +8,7 @@ import Navigation from '../../libs/Navigation/Navigation'; import variables from '../../styles/variables'; import styles from '../../styles/styles'; import useLocalize from '../../hooks/useLocalize'; +import ROUTES from '../../ROUTES'; const propTypes = { /** Child elements */ @@ -44,7 +45,7 @@ const defaultProps = { titleKey: 'notFound.notHere', subtitleKey: 'notFound.pageNotFound', linkKey: 'notFound.goBackHome', - onBackButtonPress: Navigation.goBack, + onBackButtonPress: () => Navigation.goBack(ROUTES.HOME), shouldShowLink: true, shouldShowBackButton: true, onLinkPress: () => Navigation.dismissModal(), diff --git a/src/components/DistanceRequest.js b/src/components/DistanceRequest.js index 966f700e25d4..09500fd9847a 100644 --- a/src/components/DistanceRequest.js +++ b/src/components/DistanceRequest.js @@ -189,7 +189,7 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken, useEffect(updateGradientVisibility, [scrollContainerHeight, scrollContentHeight]); const navigateBack = () => { - Navigation.goBack(isEditing ? ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID) : null); + Navigation.goBack(isEditing ? ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID) : ROUTES.HOME); }; const navigateToNextPage = () => { diff --git a/src/components/HeaderWithBackButton/index.js b/src/components/HeaderWithBackButton/index.js index cf61a4cf4eb7..aab54612e206 100755 --- a/src/components/HeaderWithBackButton/index.js +++ b/src/components/HeaderWithBackButton/index.js @@ -22,7 +22,7 @@ import useKeyboardState from '../../hooks/useKeyboardState'; function HeaderWithBackButton({ iconFill = undefined, guidesCallTaskID = '', - onBackButtonPress = () => Navigation.goBack(), + onBackButtonPress = () => Navigation.goBack(ROUTES.HOME), onCloseButtonPress = () => Navigation.dismissModal(), onDownloadButtonPress = () => {}, onThreeDotsButtonPress = () => {}, diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js index b574b4ffa205..1264ec777b28 100644 --- a/src/libs/Navigation/Navigation.js +++ b/src/libs/Navigation/Navigation.js @@ -97,7 +97,7 @@ function navigate(route = ROUTES.HOME, type) { * @param {Bool} shouldEnforceFallback - Enforces navigation to fallback route * @param {Bool} shouldPopToTop - Should we navigate to LHN on back press */ -function goBack(fallbackRoute = ROUTES.HOME, shouldEnforceFallback = false, shouldPopToTop = false) { +function goBack(fallbackRoute, shouldEnforceFallback = false, shouldPopToTop = false) { if (!canNavigate('goBack')) { return; } diff --git a/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.js b/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.js index a36fef610a39..8e16bb72f656 100644 --- a/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.js +++ b/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.js @@ -27,7 +27,7 @@ export default function subscribeToReportCommentPushNotifications() { try { // If a chat is visible other than the one we are trying to navigate to, then we need to navigate back if (Navigation.getActiveRoute().slice(1, 2) === ROUTES.REPORT && !Navigation.isActiveRoute(`r/${reportID}`)) { - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); } Log.info('[PushNotification] onSelected() - Navigation is ready. Navigating...', false, {reportID, reportActionID}); diff --git a/src/libs/actions/App.js b/src/libs/actions/App.js index 52e2dfdd8e6a..5753804eadfe 100644 --- a/src/libs/actions/App.js +++ b/src/libs/actions/App.js @@ -319,7 +319,7 @@ function createWorkspaceAndNavigateToIt(policyOwnerEmail = '', makeMeAdmin = fal .then(() => { if (transitionFromOldDot) { // We must call goBack() to remove the /transition route from history - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); } if (shouldNavigateToAdminChat) { @@ -383,7 +383,7 @@ function setUpPoliciesAndNavigate(session, shouldNavigateToAdminChat) { Navigation.isNavigationReady() .then(() => { // We must call goBack() to remove the /transition route from history - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); Navigation.navigate(exitTo); }) .then(endSignOnTransition); @@ -399,7 +399,7 @@ function redirectThirdPartyDesktopSignIn() { if (url.pathname === `/${ROUTES.GOOGLE_SIGN_IN}` || url.pathname === `/${ROUTES.APPLE_SIGN_IN}`) { Navigation.isNavigationReady().then(() => { - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); Navigation.navigate(ROUTES.DESKTOP_SIGN_IN_REDIRECT); }); } diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index a9f07cf84d9f..9e8dadbd53b7 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -1393,14 +1393,14 @@ function deleteMoneyRequest(transactionID, reportAction, isSingleTransactionView // STEP 7: Navigate the user depending on which page they are on and which resources were deleted if (isSingleTransactionView && shouldDeleteTransactionThread && !shouldDeleteIOUReport) { // Pop the deleted report screen before navigating. This prevents navigating to the Concierge chat due to the missing report. - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); Navigation.navigate(ROUTES.getReportRoute(iouReport.reportID)); return; } if (shouldDeleteIOUReport) { // Pop the deleted report screen before navigating. This prevents navigating to the Concierge chat due to the missing report. - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); Navigation.navigate(ROUTES.getReportRoute(iouReport.chatReportID)); } } diff --git a/src/libs/actions/PaymentMethods.js b/src/libs/actions/PaymentMethods.js index 17fec65078ed..0ed6f8b036bb 100644 --- a/src/libs/actions/PaymentMethods.js +++ b/src/libs/actions/PaymentMethods.js @@ -18,12 +18,12 @@ const kycWallRef = createRef(); */ function continueSetup() { if (!kycWallRef.current || !kycWallRef.current.continue) { - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); return; } // Close the screen (Add Debit Card, Add Bank Account, or Enable Payments) on success and continue with setup - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); kycWallRef.current.continue(); } diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 2a34c839a94e..e73581be0c8d 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1241,7 +1241,7 @@ function updateNotificationPreferenceAndNavigate(reportID, previousValue, newVal function updateWelcomeMessage(reportID, previousValue, newValue) { // No change needed, navigate back if (previousValue === newValue) { - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); return; } @@ -1261,7 +1261,7 @@ function updateWelcomeMessage(reportID, previousValue, newValue) { }, ]; API.write('UpdateWelcomeMessage', {reportID, welcomeMessage: parsedWelcomeMessage}, {optimisticData, failureData}); - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); } /** @@ -1438,7 +1438,7 @@ function deleteReport(reportID) { */ function navigateToConciergeChatAndDeleteReport(reportID) { // Dismiss the current report screen and replace it with Concierge Chat - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); navigateToConciergeChat(); deleteReport(reportID); } @@ -1820,7 +1820,7 @@ function leaveRoom(reportID) { ); Navigation.dismissModal(); if (Navigation.getTopmostReportId() === reportID) { - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); } navigateToConciergeChat(); } diff --git a/src/pages/AddPersonalBankAccountPage.js b/src/pages/AddPersonalBankAccountPage.js index 8ef8b71b90d0..98bc09a7a217 100644 --- a/src/pages/AddPersonalBankAccountPage.js +++ b/src/pages/AddPersonalBankAccountPage.js @@ -132,7 +132,7 @@ class AddPersonalBankAccountPage extends React.Component { this.setState({selectedPlaidAccountID}); }} plaidData={this.props.plaidData} - onExitPlaid={Navigation.goBack} + onExitPlaid={() => Navigation.goBack(ROUTES.HOME)} receivedRedirectURI={getPlaidOAuthReceivedRedirectURI()} selectedPlaidAccountID={this.state.selectedPlaidAccountID} /> diff --git a/src/pages/ConciergePage.js b/src/pages/ConciergePage.js index 610fa3587b7a..e8509024b469 100644 --- a/src/pages/ConciergePage.js +++ b/src/pages/ConciergePage.js @@ -7,6 +7,7 @@ import ONYXKEYS from '../ONYXKEYS'; import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator'; import Navigation from '../libs/Navigation/Navigation'; import * as Report from '../libs/actions/Report'; +import ROUTES from '../ROUTES'; const propTypes = { /** Session info for the currently logged in user. */ @@ -31,7 +32,7 @@ function ConciergePage(props) { useFocusEffect(() => { if (_.has(props.session, 'authToken')) { // Pop the concierge loading page before opening the concierge report. - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); Report.navigateToConciergeChat(); } else { Navigation.navigate(); diff --git a/src/pages/DetailsPage.js b/src/pages/DetailsPage.js index 7873c4daa00c..52d5fe4a7842 100755 --- a/src/pages/DetailsPage.js +++ b/src/pages/DetailsPage.js @@ -27,8 +27,6 @@ import * as Report from '../libs/actions/Report'; import OfflineWithFeedback from '../components/OfflineWithFeedback'; import AutoUpdateTime from '../components/AutoUpdateTime'; import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView'; -import Navigation from '../libs/Navigation/Navigation'; -import ROUTES from '../ROUTES'; import * as UserUtils from '../libs/UserUtils'; const matchType = PropTypes.shape({ @@ -130,10 +128,7 @@ function DetailsPage(props) { return ( - Navigation.goBack(ROUTES.HOME)} - /> + - + - +
descriptionInputRef.current && descriptionInputRef.current.focus()} > - Navigation.goBack()} - /> + merchantInputRef.current && merchantInputRef.current.focus()} > - + { - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); }} onSuccess={(data) => { BankAccounts.verifyIdentity({ diff --git a/src/pages/PrivateNotes/PrivateNotesEditPage.js b/src/pages/PrivateNotes/PrivateNotesEditPage.js index d5542d04733a..206e9e74d91f 100644 --- a/src/pages/PrivateNotes/PrivateNotesEditPage.js +++ b/src/pages/PrivateNotes/PrivateNotesEditPage.js @@ -24,6 +24,7 @@ import * as Report from '../../libs/actions/Report'; import useLocalize from '../../hooks/useLocalize'; import OfflineWithFeedback from '../../components/OfflineWithFeedback'; import focusAndUpdateMultilineInputRange from '../../libs/focusAndUpdateMultilineInputRange'; +import ROUTES from '../../ROUTES'; const propTypes = { /** All of the personal details for everyone */ @@ -72,7 +73,7 @@ function PrivateNotesEditPage({route, personalDetailsList, session, report}) { Keyboard.dismiss(); // Take user back to the PrivateNotesView page - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); }; return ( @@ -83,14 +84,12 @@ function PrivateNotesEditPage({route, personalDetailsList, session, report}) { Navigation.goBack()} > Navigation.dismissModal()} - onBackButtonPress={() => Navigation.goBack()} /> diff --git a/src/pages/PrivateNotes/PrivateNotesListPage.js b/src/pages/PrivateNotes/PrivateNotesListPage.js index f4d114b81ba1..098bfd2a245b 100644 --- a/src/pages/PrivateNotes/PrivateNotesListPage.js +++ b/src/pages/PrivateNotes/PrivateNotesListPage.js @@ -118,15 +118,11 @@ function PrivateNotesListPage({report, personalDetailsList, network, session}) { return ( - Navigation.goBack()} - > + Navigation.dismissModal()} - onBackButtonPress={() => Navigation.goBack()} /> {report.isLoadingPrivateNotes && _.isEmpty(lodashGet(report, 'privateNotes', {})) ? ( diff --git a/src/pages/PrivateNotes/PrivateNotesViewPage.js b/src/pages/PrivateNotes/PrivateNotesViewPage.js index abaa9df8d1f4..48f053f10f90 100644 --- a/src/pages/PrivateNotes/PrivateNotesViewPage.js +++ b/src/pages/PrivateNotes/PrivateNotesViewPage.js @@ -60,14 +60,12 @@ function PrivateNotesViewPage({route, personalDetailsList, session, report}) { Navigation.goBack()} > Navigation.dismissModal()} - onBackButtonPress={() => Navigation.goBack()} /> diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index 19f2b1fdc0c6..b515da04b7be 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -139,7 +139,7 @@ function ProfilePage(props) { const hasStatus = !!statusEmojiCode && Permissions.canUseCustomStatus(props.betas); const statusContent = `${statusEmojiCode} ${statusText}`; - const navigateBackTo = lodashGet(props.route, 'params.backTo', ''); + const navigateBackTo = lodashGet(props.route, 'params.backTo', ROUTES.HOME); const chatReportWithCurrentUser = !isCurrentUser && !Session.isAnonymousUser() ? ReportUtils.getChatByParticipants([accountID]) : 0; diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 3160ad590c50..cdb3aeebe924 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -284,7 +284,7 @@ class ReimbursementAccountPage extends React.Component { const currentStep = achData.currentStep || CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT; const subStep = achData.subStep; const shouldShowOnfido = this.props.onfidoToken && !achData.isOnfidoSetupComplete; - const backTo = lodashGet(this.props.route.params, 'backTo'); + const backTo = lodashGet(this.props.route.params, 'backTo', ROUTES.HOME); switch (currentStep) { case CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT: if (this.hasInProgressVBBA()) { @@ -405,7 +405,7 @@ class ReimbursementAccountPage extends React.Component { continue={this.continue} policyName={policyName} onBackButtonPress={() => { - Navigation.goBack(lodashGet(this.props.route.params, 'backTo')); + Navigation.goBack(lodashGet(this.props.route.params, 'backTo', ROUTES.HOME)); }} /> ); diff --git a/src/pages/TeachersUnite/SaveTheWorldPage.js b/src/pages/TeachersUnite/SaveTheWorldPage.js index 47c441ad934c..1fb863051da5 100644 --- a/src/pages/TeachersUnite/SaveTheWorldPage.js +++ b/src/pages/TeachersUnite/SaveTheWorldPage.js @@ -53,7 +53,7 @@ function SaveTheWorldPage(props) { Navigation.goBack(ROUTES.HOME)} backgroundColor={themeColors.PAGE_BACKGROUND_COLORS[ROUTES.I_KNOW_A_TEACHER]} illustration={LottieAnimations.SaveTheWorld} > diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 8528b8f213a9..63e60a545de9 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -328,7 +328,6 @@ function ReportScreen({ subtitleKey="notFound.noAccess" shouldShowCloseButton={false} shouldShowBackButton={isSmallScreenWidth} - onBackButtonPress={Navigation.goBack} shouldShowLink={false} > { - Navigation.goBack(isEditing ? ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID) : null); + Navigation.goBack(isEditing ? ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID) : ROUTES.HOME); }; const navigateToCurrencySelectionPage = () => { diff --git a/src/pages/signin/SignInModal.js b/src/pages/signin/SignInModal.js index 0cd566a47327..50b0af0bfa05 100644 --- a/src/pages/signin/SignInModal.js +++ b/src/pages/signin/SignInModal.js @@ -23,7 +23,7 @@ function SignInModal() { includeSafeAreaPaddingBottom={false} shouldEnableMaxHeight > - Navigation.goBack()} /> + ); diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.js b/src/pages/workspace/WorkspaceInviteMessagePage.js index 9a046d7fe4c2..3baf84f54ccf 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.js +++ b/src/pages/workspace/WorkspaceInviteMessagePage.js @@ -122,7 +122,7 @@ class WorkspaceInviteMessagePage extends React.Component { Policy.addMembersToWorkspace(this.props.invitedEmailsToAccountIDsDraft, this.state.welcomeNote, this.props.route.params.policyID); Policy.setWorkspaceInviteMembersDraft(this.props.route.params.policyID, {}); // Pop the invite message page before navigating to the members page. - Navigation.goBack(); + Navigation.goBack(ROUTES.HOME); Navigation.navigate(ROUTES.getWorkspaceMembersRoute(this.props.route.params.policyID)); } @@ -171,7 +171,6 @@ class WorkspaceInviteMessagePage extends React.Component { guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS} shouldShowBackButton onCloseButtonPress={() => Navigation.dismissModal()} - onBackButtonPress={() => Navigation.goBack()} />