Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wave 8] [Ideal Nav] goBack update fallback route #36050

Merged
3 changes: 1 addition & 2 deletions src/components/BlockingViews/FullPageNotFoundView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import variables from '@styles/variables';
import type {TranslationPaths} from '@src/languages/types';
import ROUTES from '@src/ROUTES';
import BlockingView from './BlockingView';
import ForceFullScreenView from './ForceFullScreenView';

Expand Down Expand Up @@ -50,7 +49,7 @@ function FullPageNotFoundView({
titleKey = 'notFound.notHere',
subtitleKey = 'notFound.pageNotFound',
linkKey = 'notFound.goBackHome',
onBackButtonPress = () => Navigation.goBack(ROUTES.HOME),
onBackButtonPress = () => Navigation.goBack(),
shouldShowLink = true,
shouldShowBackButton = true,
onLinkPress = () => Navigation.dismissModal(),
Expand Down
2 changes: 1 addition & 1 deletion src/components/HeaderWithBackButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function HeaderWithBackButton({
icon,
iconFill,
guidesCallTaskID = '',
onBackButtonPress = () => Navigation.goBack(ROUTES.HOME),
onBackButtonPress = () => Navigation.goBack(),
onCloseButtonPress = () => Navigation.dismissModal(),
onDownloadButtonPress = () => {},
onThreeDotsButtonPress = () => {},
Expand Down
2 changes: 1 addition & 1 deletion src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function MoneyReportHeader({session, policy, chatReport, nextStep, report: money
policy={policy}
personalDetails={personalDetails}
shouldShowBackButton={isSmallScreenWidth}
onBackButtonPress={() => Navigation.goBack(ROUTES.HOME, false, true)}
onBackButtonPress={() => Navigation.goBack(undefined, false, true)}
// Shows border if no buttons or next steps are showing below the header
shouldShowBorderBottom={!(shouldShowAnyButton && isSmallScreenWidth) && !(shouldShowNextStep && !isSmallScreenWidth)}
shouldShowThreeDotsButton
Expand Down
2 changes: 1 addition & 1 deletion src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction,
policy={policy}
personalDetails={personalDetails}
shouldShowBackButton={isSmallScreenWidth}
onBackButtonPress={() => Navigation.goBack(ROUTES.HOME, false, true)}
onBackButtonPress={() => Navigation.goBack(undefined, false, true)}
/>
{isPending && (
<MoneyRequestHeaderStatusBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ const isAtLeastOneInState = (state: StackState, screenName: string): boolean =>

function adaptStateIfNecessary(state: StackState) {
const isNarrowLayout = getIsNarrowLayout();

// There should always be SETTINGS.ROOT screen in the state to make sure go back works properly if we deeplinkg to a subpage of settings.
if (!isAtLeastOneInState(state, SCREENS.SETTINGS.ROOT)) {
// @ts-expect-error Updating read only property
// noinspection JSConstantReassignment
state.stale = true; // eslint-disable-line

// This is necessary for ts to narrow type down to PartialState.
if (state.stale === true) {
// Unshift the root screen to fill left pane.
state.routes.unshift({name: SCREENS.SETTINGS.ROOT});
}
}

// If the screen is wide, there should be at least two screens inside:
// - SETINGS.ROOT to cover left pane.
// - SETTINGS_CENTRAL_PANE to cover central pane.
if (!isNarrowLayout) {
if (!isAtLeastOneInState(state, SCREENS.SETTINGS.ROOT)) {
// @ts-expect-error Updating read only property
// noinspection JSConstantReassignment
state.stale = true; // eslint-disable-line

// This is necessary for ts to narrow type down to PartialState.
if (state.stale === true) {
// Unshift the root screen to fill left pane.
state.routes.unshift({name: SCREENS.SETTINGS.ROOT});
}
}
if (!isAtLeastOneInState(state, SCREENS.SETTINGS_CENTRAL_PANE)) {
// @ts-expect-error Updating read only property
// noinspection JSConstantReassignment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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(ROUTES.HOME);
Navigation.goBack();
}

Log.info('[PushNotification] onSelected() - Navigation is ready. Navigating...', false, {reportID, reportActionID});
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt(policyOwnerEmail = '', po
.then(() => {
if (transitionFromOldDot) {
// We must call goBack() to remove the /transition route from history
Navigation.goBack(ROUTES.HOME);
Navigation.goBack();
}
Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policyID));
})
Expand Down Expand Up @@ -390,7 +390,7 @@ function setUpPoliciesAndNavigate(session: OnyxEntry<OnyxTypes.Session>) {
Navigation.waitForProtectedRoutes()
.then(() => {
// We must call goBack() to remove the /transition route from history
Navigation.goBack(ROUTES.HOME);
Navigation.goBack();
Navigation.navigate(exitTo);
})
.then(endSignOnTransition);
Expand All @@ -406,7 +406,7 @@ function redirectThirdPartyDesktopSignIn() {

if (url.pathname === `/${ROUTES.GOOGLE_SIGN_IN}` || url.pathname === `/${ROUTES.APPLE_SIGN_IN}`) {
Navigation.isNavigationReady().then(() => {
Navigation.goBack(ROUTES.HOME);
Navigation.goBack();
Navigation.navigate(ROUTES.DESKTOP_SIGN_IN_REDIRECT);
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ function deleteReport(reportID: string) {
*/
function navigateToConciergeChatAndDeleteReport(reportID: string) {
// Dismiss the current report screen and replace it with Concierge Chat
Navigation.goBack(ROUTES.HOME);
Navigation.goBack();
navigateToConciergeChat();
deleteReport(reportID);
}
Expand Down Expand Up @@ -2276,14 +2276,14 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal

if (lastAccessedReportID) {
// We should call Navigation.goBack to pop the current route first before navigating to Concierge.
Navigation.goBack(ROUTES.HOME);
Navigation.goBack();
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(lastAccessedReportID));
} else {
const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.CONCIERGE]);
const chat = ReportUtils.getChatByParticipants(participantAccountIDs);
if (chat?.reportID) {
// We should call Navigation.goBack to pop the current route first before navigating to Concierge.
Navigation.goBack(ROUTES.HOME);
Navigation.goBack();
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chat.reportID));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/AddPersonalBankAccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function AddPersonalBankAccountPage({personalBankAccount, plaidData}: AddPersona
<AddPlaidBankAccount
onSelect={setSelectedPlaidAccountId}
plaidData={plaidData}
onExitPlaid={() => Navigation.goBack(ROUTES.HOME)}
onExitPlaid={() => Navigation.goBack()}
receivedRedirectURI={getPlaidOAuthReceivedRedirectURI()}
selectedPlaidAccountID={selectedPlaidAccountId}
/>
Expand Down
3 changes: 1 addition & 2 deletions src/pages/ConciergePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Navigation from '@libs/Navigation/Navigation';
import type {AuthScreensParamList} from '@libs/Navigation/types';
import * as Report from '@userActions/Report';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import type {Session} from '@src/types/onyx';

Expand All @@ -29,7 +28,7 @@ function ConciergePage({session}: ConciergePageProps) {
if (session && 'authToken' in session) {
// Pop the concierge loading page before opening the concierge report.
Navigation.isNavigationReady().then(() => {
Navigation.goBack(ROUTES.HOME);
Navigation.goBack();
Report.navigateToConciergeChat();
});
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/EnablePayments/OnfidoStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import * as BankAccounts from '@userActions/BankAccounts';
import * as Wallet from '@userActions/Wallet';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import OnfidoPrivacy from './OnfidoPrivacy';
import walletOnfidoDataPropTypes from './walletOnfidoDataPropTypes';

Expand All @@ -32,7 +31,7 @@ function OnfidoStep({walletOnfidoData}) {
const shouldShowOnfido = walletOnfidoData.hasAcceptedPrivacyPolicy && !walletOnfidoData.isLoading && !walletOnfidoData.error && walletOnfidoData.sdkToken;

const goBack = useCallback(() => {
Navigation.goBack(ROUTES.HOME);
Navigation.goBack();
}, []);

const goToPreviousStep = useCallback(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ShareCodePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function ShareCodePage({report, session, currentUserPersonalDetails}: ShareCodeP
>
<HeaderWithBackButton
title={translate('common.shareCode')}
onBackButtonPress={() => Navigation.goBack(isReport ? ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID) : ROUTES.SETTINGS)}
onBackButtonPress={() => Navigation.goBack(isReport ? ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID) : undefined)}
shouldShowBackButton={isReport || isSmallScreenWidth}
icon={Illustrations.QrCode}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function ReportScreen({
}, [shouldHideReport, report]);

const goBack = useCallback(() => {
Navigation.goBack(ROUTES.HOME, false, true);
Navigation.goBack(undefined, false, true);
}, []);

let headerView = (
Expand Down Expand Up @@ -423,7 +423,7 @@ function ReportScreen({
Navigation.dismissModal();
if (Navigation.getTopmostReportId() === prevOnyxReportID) {
Navigation.setShouldPopAllStateOnUP();
Navigation.goBack(ROUTES.HOME, false, true);
Navigation.goBack(undefined, false, true);
}
if (prevReport.parentReportID) {
// Prevent navigation to the Money Request Report if it is pending deletion.
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/IOUCurrencySelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function IOUCurrencySelection(props) {
// Navigating to "backTo" will result in forward navigation instead, causing disruption to the currency selection.
// To prevent any negative experience, we have made the decision to simply close the currency selection page.
if (_.isEmpty(backTo) || props.navigation.getState().routes.length === 1) {
Navigation.goBack(ROUTES.HOME);
Navigation.goBack();
} else {
Navigation.navigate(`${props.route.params.backTo}?currency=${option.currencyCode}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepAmount.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function IOURequestStepAmount({
}, []);

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Navigation.goBack(backTo);
};

const navigateToCurrencySelectionPage = () => {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/iou/request/step/IOURequestStepCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import compose from '@libs/compose';
import Navigation from '@libs/Navigation/Navigation';
import reportPropTypes from '@pages/reportPropTypes';
import * as IOU from '@userActions/IOU';
import ROUTES from '@src/ROUTES';
import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes';
import StepScreenWrapper from './StepScreenWrapper';
import withFullTransactionOrNotFound from './withFullTransactionOrNotFound';
Expand Down Expand Up @@ -42,7 +41,7 @@ function IOURequestStepCategory({
const {translate} = useLocalize();

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Navigation.goBack(backTo);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepCurrency.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function IOURequestStepCurrency({
Navigation.goBack(routeToAmountPageWithConfirmationAsBackTo);
return;
}
Navigation.goBack(backTo || ROUTES.HOME);
Navigation.goBack(backTo);
};

/**
Expand Down
3 changes: 1 addition & 2 deletions src/pages/iou/request/step/IOURequestStepDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Navigation from '@libs/Navigation/Navigation';
import * as IOU from '@userActions/IOU';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes';
import StepScreenWrapper from './StepScreenWrapper';
import withFullTransactionOrNotFound from './withFullTransactionOrNotFound';
Expand Down Expand Up @@ -40,7 +39,7 @@ function IOURequestStepDate({
const {translate} = useLocalize();

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Navigation.goBack(backTo);
};

/**
Expand Down
3 changes: 1 addition & 2 deletions src/pages/iou/request/step/IOURequestStepDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import updateMultilineInputRange from '@libs/updateMultilineInputRange';
import * as IOU from '@userActions/IOU';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes';
import StepScreenWrapper from './StepScreenWrapper';
import withFullTransactionOrNotFound from './withFullTransactionOrNotFound';
Expand Down Expand Up @@ -72,7 +71,7 @@ function IOURequestStepDescription({
);

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Beamanator marked this conversation as resolved.
Show resolved Hide resolved
Navigation.goBack(backTo);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepDistance.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function IOURequestStepDistance({
}, [numberOfPreviousWaypoints, numberOfWaypoints]);

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Navigation.goBack(backTo);
};

/**
Expand Down
3 changes: 1 addition & 2 deletions src/pages/iou/request/step/IOURequestStepMerchant.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Navigation from '@libs/Navigation/Navigation';
import * as IOU from '@userActions/IOU';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes';
import StepScreenWrapper from './StepScreenWrapper';
import withFullTransactionOrNotFound from './withFullTransactionOrNotFound';
Expand Down Expand Up @@ -46,7 +45,7 @@ function IOURequestStepMerchant({
const isMerchantRequired = _.some(participants, (participant) => Boolean(participant.isPolicyExpenseChat));

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Navigation.goBack(backTo);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepScan/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function IOURequestStepScan({
}

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Navigation.goBack(backTo);
};

const navigateToConfirmationStep = useCallback(() => {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/iou/request/step/IOURequestStepTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import reportPropTypes from '@pages/reportPropTypes';
import * as IOU from '@userActions/IOU';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes';
import StepScreenWrapper from './StepScreenWrapper';
import withFullTransactionOrNotFound from './withFullTransactionOrNotFound';
Expand Down Expand Up @@ -59,7 +58,7 @@ function IOURequestStepTag({
const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT;

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Navigation.goBack(backTo);
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function IOURequestStepTaxAmountPage({
);

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Navigation.goBack(backTo);
};

const navigateToCurrencySelectionPage = () => {
Expand Down
5 changes: 2 additions & 3 deletions src/pages/iou/request/step/IOURequestStepTaxRatePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import * as IOU from '@userActions/IOU';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes';
import withFullTransactionOrNotFound from './withFullTransactionOrNotFound';
import withWritableReportOrNotFound from './withWritableReportOrNotFound';
Expand Down Expand Up @@ -51,7 +50,7 @@ function IOURequestStepTaxRatePage({
const {translate} = useLocalize();

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Navigation.goBack(backTo);
};

const defaultTaxKey = policyTaxRates.defaultExternalID;
Expand All @@ -64,7 +63,7 @@ function IOURequestStepTaxRatePage({
IOU.setMoneyRequestTaxRate(transaction.transactionID, taxes);
IOU.setMoneyRequestTaxAmount(transaction.transactionID, amountInSmallestCurrencyUnits);

Navigation.goBack(backTo || ROUTES.HOME);
Navigation.goBack(backTo);
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Profile/CustomStatus/StatusPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function StatusPage({draftStatus, currentUserPersonalDetails}) {
return DateUtils.isTimeAtLeastOneMinuteInFuture({dateTimeString: clearAfterTime});
}, [draftClearAfter, currentUserClearAfter]);

const navigateBackToPreviousScreen = useCallback(() => Navigation.goBack('', false, true), []);
const navigateBackToPreviousScreen = useCallback(() => Navigation.goBack(), []);
const updateStatus = useCallback(
({emojiCode, statusText}) => {
const clearAfterTime = draftClearAfter || currentUserClearAfter || CONST.CUSTOM_STATUS_TYPES.NEVER;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Profile/ProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function ProfilePage(props) {
>
<HeaderWithBackButton
title={props.translate('common.profile')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)}
onBackButtonPress={() => Navigation.goBack()}
shouldShowBackButton={props.isSmallScreenWidth}
icon={Illustrations.Profile}
/>
Expand Down
Loading
Loading