diff --git a/src/ROUTES.ts b/src/ROUTES.ts
index ac8e4a090e64..ddc73099eea9 100644
--- a/src/ROUTES.ts
+++ b/src/ROUTES.ts
@@ -1316,11 +1316,13 @@ const ROUTES = {
},
SETTINGS_WALLET_REPORT_CARD_LOST_OR_DAMAGED: {
route: 'settings/wallet/card/:cardID/report-card-lost-or-damaged',
- getRoute: (cardID: string) => `settings/wallet/card/${cardID}/report-card-lost-or-damaged` as const,
+ getRoute: (cardID: string, isFromDomainCardDetail?: boolean) =>
+ `settings/wallet/card/${cardID}/report-card-lost-or-damaged${isFromDomainCardDetail ? '?isFromDomainCardDetail=true' : ''}` as const,
},
SETTINGS_WALLET_REPORT_CARD_LOST_OR_DAMAGED_CONFIRM_MAGIC_CODE: {
route: 'settings/wallet/card/:cardID/report-card-lost-or-damaged/:reason/confirm-magic-code',
- getRoute: (cardID: string, reason: ReplacementReason) => `settings/wallet/card/${cardID}/report-card-lost-or-damaged/${reason}/confirm-magic-code` as const,
+ getRoute: (cardID: string, reason: ReplacementReason, isFromDomainCardDetail?: boolean) =>
+ `settings/wallet/card/${cardID}/report-card-lost-or-damaged/${reason}/confirm-magic-code${isFromDomainCardDetail ? '?isFromDomainCardDetail=true' : ''}` as const,
},
SETTINGS_WALLET_CARD_CHANGE_PIN: {
route: 'settings/wallet/card/:cardID/change-pin',
@@ -1332,7 +1334,7 @@ const ROUTES = {
},
SETTINGS_WALLET_CARD_ACTIVATE: {
route: 'settings/wallet/card/:cardID/activate',
- getRoute: (cardID: string) => `settings/wallet/card/${cardID}/activate` as const,
+ getRoute: (cardID: string, isFromDomainCardDetail?: boolean) => `settings/wallet/card/${cardID}/activate${isFromDomainCardDetail ? '?isFromDomainCardDetail=true' : ''}` as const,
},
SETTINGS_WALLET_TRAVEL_CVV: 'settings/wallet/travel-cvv',
SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNT: `settings/wallet/travel-cvv/${VERIFY_ACCOUNT}`,
diff --git a/src/components/ScreenWrapper/index.tsx b/src/components/ScreenWrapper/index.tsx
index 7d3e4d5da5bb..fc31fbced0cf 100644
--- a/src/components/ScreenWrapper/index.tsx
+++ b/src/components/ScreenWrapper/index.tsx
@@ -24,6 +24,7 @@ import type {ForwardedFSClassProps} from '@libs/Fullstory/types';
import getPlatform from '@libs/getPlatform';
import mergeRefs from '@libs/mergeRefs';
import NarrowPaneContext from '@libs/Navigation/AppNavigator/Navigators/NarrowPaneContext';
+import doesInitialURLMatchActiveRoute from '@libs/Navigation/helpers/doesInitialURLMatchActiveRoute';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackNavigationProp} from '@libs/Navigation/PlatformStackNavigation/types';
import type {ReportsSplitNavigatorParamList, RightModalNavigatorParamList, RootNavigatorParamList} from '@libs/Navigation/types';
@@ -191,12 +192,12 @@ function ScreenWrapper({
useEffect(() => {
Navigation.isNavigationReady().then(() => setInitialActiveRouteWithoutParams(Navigation.getActiveRouteWithoutParams()));
}, []);
- const initialURLWithoutParams = initialURL?.replaceAll(/\?.*/g, '');
- const doesInitialURLMatchActiveRoute = !!initialURLWithoutParams?.endsWith(Navigation.getActiveRouteWithoutParams() || initialActiveRouteWithoutParams);
+ const activeRouteWithoutParams = Navigation.getActiveRouteWithoutParams() || initialActiveRouteWithoutParams;
+ const initialURLMatchesActiveRoute = doesInitialURLMatchActiveRoute(initialURL, activeRouteWithoutParams);
// A multifactor authentication flow (e.g. Face ID to reveal UK/EU card details) renders in an independent navigation tree
// overlaid above the single NewDot entry, and each MFA screen renders its own ScreenWrapper. Navigation.getActiveRouteWithoutParams()
- // still reports the underlying NewDot route while the overlay is up, so doesInitialURLMatchActiveRoute is true on the MFA screens too.
+ // still reports the underlying NewDot route while the overlay is up, so initialURLMatchesActiveRoute is true on the MFA screens too.
// usePreventRemove calls e.preventDefault() unconditionally whenever the guard is active, so guarding these instances would consume the
// MFA navigator's own stack actions (e.g. replacing the magic-code page with the Face ID prompt, or popping the outcome screen on close),
// blocking transitions within the flow. Guard only the outer NewDot ScreenWrapper, never the ScreenWrappers inside the MFA overlay.
@@ -204,7 +205,7 @@ function ScreenWrapper({
const route = useContext(NavigationRouteContext ?? FallbackRouteContext);
const isMfaOverlayScreen = !!route && MFA_OVERLAY_SCREENS.has(route.name);
- usePreventRemove(isSingleNewDotEntry && doesInitialURLMatchActiveRoute && !shouldBlockSingleEntryOldAppExit && !isMfaOverlayScreen, () => {
+ usePreventRemove(isSingleNewDotEntry && initialURLMatchesActiveRoute && !shouldBlockSingleEntryOldAppExit && !isMfaOverlayScreen, () => {
if (!CONFIG.IS_HYBRID_APP) {
return;
}
diff --git a/src/libs/Navigation/helpers/doesInitialURLMatchActiveRoute.ts b/src/libs/Navigation/helpers/doesInitialURLMatchActiveRoute.ts
new file mode 100644
index 000000000000..25f395e54aff
--- /dev/null
+++ b/src/libs/Navigation/helpers/doesInitialURLMatchActiveRoute.ts
@@ -0,0 +1,26 @@
+import type {Route} from '@src/ROUTES';
+
+/**
+ * Reporting a card lost from a card deep-linked by OldDot (settings/card/:cardID) deletes the original card and lands the
+ * user on the replacement card's route. The cardID segment changes, so a plain comparison would no longer match the initial
+ * URL. Normalize the cardID segment so the same card-detail screen still counts as a match regardless of which card is shown.
+ */
+function normalizeDomainCardDetailRoute(path: string): string {
+ return path.replace(/(^|\/)settings\/card\/[^/?]+/, '$1settings/card/:cardID');
+}
+
+/**
+ * Whether the initial URL that launched NewDot still matches the currently active route. Used to decide whether the
+ * HybridApp single-entry back handoff should fire (i.e. the user is still on the screen OldDot deep-linked into).
+ */
+function doesInitialURLMatchActiveRoute(initialURL: Route | null, activeRouteWithoutParams: string): boolean {
+ const initialURLWithoutParams = initialURL?.replaceAll(/\?.*/g, '');
+
+ if (!initialURLWithoutParams) {
+ return false;
+ }
+
+ return normalizeDomainCardDetailRoute(initialURLWithoutParams).endsWith(normalizeDomainCardDetailRoute(activeRouteWithoutParams));
+}
+
+export default doesInitialURLMatchActiveRoute;
diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts
index 4a4452b00f9f..3bfbbf77250e 100644
--- a/src/libs/Navigation/types.ts
+++ b/src/libs/Navigation/types.ts
@@ -177,6 +177,9 @@ type SettingsNavigatorParamList = {
[SCREENS.SETTINGS.WALLET.CARD_ACTIVATE]: {
/** cardID of selected card */
cardID: string;
+
+ /** Whether the flow was launched from the top-level DomainCard route (deep-linked from OldDot) rather than the Settings wallet card route */
+ isFromDomainCardDetail?: string;
};
[SCREENS.SETTINGS.WALLET.CARD_CHANGE_PIN]: {
/** cardID of selected card */
@@ -1222,6 +1225,9 @@ type SettingsNavigatorParamList = {
[SCREENS.SETTINGS.REPORT_CARD_LOST_OR_DAMAGED]: {
/** cardID of selected card */
cardID: string;
+
+ /** Whether the flow was launched from the top-level DomainCard route (deep-linked from OldDot) rather than the Settings wallet card route */
+ isFromDomainCardDetail?: string;
};
[SCREENS.SETTINGS.REPORT_CARD_LOST_OR_DAMAGED_CONFIRM_MAGIC_CODE]: {
/** cardID of selected card */
@@ -1229,6 +1235,9 @@ type SettingsNavigatorParamList = {
/** Reason for replacing the card */
reason: ReplacementReason;
+
+ /** Whether the flow was launched from the top-level DomainCard route (deep-linked from OldDot) rather than the Settings wallet card route */
+ isFromDomainCardDetail?: string;
};
[SCREENS.SETTINGS.DYNAMIC_KEYBOARD_SHORTCUTS]: undefined;
[SCREENS.WORKSPACE.TAX_CREATE]: {
diff --git a/src/pages/settings/Wallet/ActivatePhysicalCardPage.tsx b/src/pages/settings/Wallet/ActivatePhysicalCardPage.tsx
index 046bef1b7541..b548970a31ab 100644
--- a/src/pages/settings/Wallet/ActivatePhysicalCardPage.tsx
+++ b/src/pages/settings/Wallet/ActivatePhysicalCardPage.tsx
@@ -8,10 +8,15 @@ type ActivatePhysicalCardPageProps = PlatformStackScreenProps;
+ return (
+
+ );
}
export default ActivatePhysicalCardPage;
diff --git a/src/pages/settings/Wallet/ActivatePhysicalCardPageBase.tsx b/src/pages/settings/Wallet/ActivatePhysicalCardPageBase.tsx
index 12957042e411..cb568d06a3ed 100644
--- a/src/pages/settings/Wallet/ActivatePhysicalCardPageBase.tsx
+++ b/src/pages/settings/Wallet/ActivatePhysicalCardPageBase.tsx
@@ -26,11 +26,14 @@ import {getEmptyObject, isEmptyObject} from '@src/types/utils/EmptyObject';
type ActivatePhysicalCardPageBaseProps = {
cardID?: string;
navigateBackTo?: Route;
+
+ /** Whether the flow was launched from the top-level DomainCard route (deep-linked from OldDot) rather than the Settings wallet card route */
+ isFromDomainCardDetail?: boolean;
};
const LAST_FOUR_DIGITS_LENGTH = 4;
-function ActivatePhysicalCardPageBase({cardID = '', navigateBackTo}: ActivatePhysicalCardPageBaseProps) {
+function ActivatePhysicalCardPageBase({cardID = '', navigateBackTo, isFromDomainCardDetail = false}: ActivatePhysicalCardPageBaseProps) {
const theme = useTheme();
const styles = useThemeStyles();
const {isExtraSmallScreenHeight} = useResponsiveLayout();
@@ -48,15 +51,18 @@ function ActivatePhysicalCardPageBase({cardID = '', navigateBackTo}: ActivatePhy
const activateCardCodeInputRef = useRef(null);
/**
- * If state of the card is CONST.EXPENSIFY_CARD.STATE.OPEN, navigate to card details screen.
+ * If state of the card is CONST.EXPENSIFY_CARD.STATE.OPEN, return to the card details screen.
*/
useEffect(() => {
if (inactiveCard?.state !== CONST.EXPENSIFY_CARD.STATE.OPEN || inactiveCard?.isLoading) {
return;
}
- Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAIN_CARD.getRoute(cardID));
- }, [cardID, cardList, inactiveCard?.isLoading, inactiveCard?.state]);
+ // Collapse the activate flow back onto the existing card route instead of pushing a new one, so the user is not left
+ // with a duplicate card details screen and a stale route to back through.
+ const cardDetailRoute = isFromDomainCardDetail ? ROUTES.SETTINGS_DOMAIN_CARD_DETAIL.getRoute(cardID) : ROUTES.SETTINGS_WALLET_DOMAIN_CARD.getRoute(cardID);
+ Navigation.goBack(cardDetailRoute, {compareParams: false});
+ }, [cardID, cardList, inactiveCard?.isLoading, inactiveCard?.state, isFromDomainCardDetail]);
useEffect(() => {
if (!inactiveCard?.cardID) {
@@ -100,7 +106,9 @@ function ActivatePhysicalCardPageBase({cardID = '', navigateBackTo}: ActivatePhy
return (
Navigation.goBack(navigateBackTo ?? ROUTES.SETTINGS_WALLET_DOMAIN_CARD.getRoute(cardID))}
+ onBackButtonPress={() =>
+ Navigation.goBack(navigateBackTo ?? (isFromDomainCardDetail ? ROUTES.SETTINGS_DOMAIN_CARD_DETAIL.getRoute(cardID) : ROUTES.SETTINGS_WALLET_DOMAIN_CARD.getRoute(cardID)))
+ }
backgroundColor={theme.PAGE_THEMES[SCREENS.SETTINGS.PREFERENCES.ROOT].backgroundColor}
illustration={LottieAnimations.Magician}
scrollViewContainerStyles={[styles.mnh100]}
diff --git a/src/pages/settings/Wallet/ExpensifyCardPage/index.tsx b/src/pages/settings/Wallet/ExpensifyCardPage/index.tsx
index 5ea4af7906b2..538c6eb33c3f 100644
--- a/src/pages/settings/Wallet/ExpensifyCardPage/index.tsx
+++ b/src/pages/settings/Wallet/ExpensifyCardPage/index.tsx
@@ -5,6 +5,7 @@ import {View} from 'react-native';
import type {OnyxCollection} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import cardScarf from '@assets/images/card-scarf.svg';
+import ActivityIndicator from '@components/ActivityIndicator';
import AddToWalletButton from '@components/AddToWalletButton/index';
import Button from '@components/Button';
import CardPreview from '@components/CardPreview';
@@ -63,6 +64,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type {Policy} from '@src/types/onyx';
+import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
import {useExpensifyCardActions, useExpensifyCardState} from './ExpensifyCardContextProvider';
type ExpensifyCardPageProps =
@@ -94,6 +96,9 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
const [countryByIp] = useOnyx(ONYXKEYS.COUNTRY);
const cardList = useNonPersonalCardList();
+ const [, cardListResult] = useOnyx(ONYXKEYS.CARD_LIST);
+ const [hasLoadedApp] = useOnyx(ONYXKEYS.HAS_LOADED_APP);
+ const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP);
const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${cardList?.[cardID]?.fundID}`);
const styles = useThemeStyles();
const {isOffline} = useNetwork();
@@ -272,6 +277,27 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
const navigateToTransactions = () => navigateToCardTransactions(cardID);
+ // Show the loading indicator instead of the NotFoundPage while the card could still arrive: Before the app has loaded for the first time (hasLoadedApp),
+ // while an OpenApp/reconnect is in flight (isLoadingApp), or while CARD_LIST is still hydrating.
+ const isLoadingCardData = !currentCard && (!hasLoadedApp || !!isLoadingApp || isLoadingOnyxValue(cardListResult));
+
+ if (isLoadingCardData) {
+ return (
+
+ Navigation.closeRHPFlow()}
+ />
+
+
+
+
+ );
+ }
+
if (!currentCard) {
return Navigation.goBack(ROUTES.SETTINGS_WALLET)} />;
}
@@ -606,7 +632,12 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
showLockedAccountModal();
return;
}
- Navigation.navigate(ROUTES.SETTINGS_WALLET_REPORT_CARD_LOST_OR_DAMAGED.getRoute(String(currentPhysicalCard?.cardID)));
+ Navigation.navigate(
+ ROUTES.SETTINGS_WALLET_REPORT_CARD_LOST_OR_DAMAGED.getRoute(
+ String(currentPhysicalCard?.cardID),
+ route.name === SCREENS.DOMAIN_CARD.DOMAIN_CARD_DETAIL,
+ ),
+ );
}}
/>
)}
@@ -638,7 +669,9 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
success
large
style={[styles.w100, styles.p5]}
- onPress={() => Navigation.navigate(ROUTES.SETTINGS_WALLET_CARD_ACTIVATE.getRoute(String(currentPhysicalCard?.cardID)))}
+ onPress={() =>
+ Navigation.navigate(ROUTES.SETTINGS_WALLET_CARD_ACTIVATE.getRoute(String(currentPhysicalCard?.cardID), route.name === SCREENS.DOMAIN_CARD.DOMAIN_CARD_DETAIL))
+ }
text={translate('activateCardPage.activatePhysicalCard')}
/>
)}
diff --git a/src/pages/settings/Wallet/ReportCardLostConfirmMagicCodePage.tsx b/src/pages/settings/Wallet/ReportCardLostConfirmMagicCodePage.tsx
index 1be8cbd1ad33..4f1234e8573c 100644
--- a/src/pages/settings/Wallet/ReportCardLostConfirmMagicCodePage.tsx
+++ b/src/pages/settings/Wallet/ReportCardLostConfirmMagicCodePage.tsx
@@ -23,7 +23,7 @@ type ReportCardLostConfirmMagicCodePageProps = PlatformStackScreenProps
Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAIN_CARD.getRoute(newCardID))}
+ onBackButtonPress={() =>
+ Navigation.goBack(isFromDomainCardDetail ? ROUTES.SETTINGS_DOMAIN_CARD_DETAIL.getRoute(newCardID) : ROUTES.SETTINGS_WALLET_DOMAIN_CARD.getRoute(newCardID), {
+ compareParams: false,
+ })
+ }
+ />
+
-
);
}
diff --git a/src/pages/settings/Wallet/ReportCardLostPage.tsx b/src/pages/settings/Wallet/ReportCardLostPage.tsx
index 3824f857e49a..6be7eeedba6c 100644
--- a/src/pages/settings/Wallet/ReportCardLostPage.tsx
+++ b/src/pages/settings/Wallet/ReportCardLostPage.tsx
@@ -50,7 +50,7 @@ type ReportCardLostPageProps = PlatformStackScreenProps {
@@ -117,7 +117,8 @@ function ReportCardLostPage({
return;
}
- Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAIN_CARD.getRoute(cardID));
+ const cardDetailRoute = isFromDomainCardDetail ? ROUTES.SETTINGS_DOMAIN_CARD_DETAIL.getRoute(cardID) : ROUTES.SETTINGS_WALLET_DOMAIN_CARD.getRoute(cardID);
+ Navigation.goBack(cardDetailRoute, {compareParams: false});
};
const isDamaged = reason?.key === OPTIONS_KEYS.DAMAGED;
diff --git a/src/pages/settings/Wallet/SuccessReportCardLost.tsx b/src/pages/settings/Wallet/SuccessReportCardLost.tsx
index 2bb8e5e78bea..e4f0fc29635b 100644
--- a/src/pages/settings/Wallet/SuccessReportCardLost.tsx
+++ b/src/pages/settings/Wallet/SuccessReportCardLost.tsx
@@ -7,7 +7,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import ROUTES from '@src/ROUTES';
-function SuccessReportCardLost({cardID}: {cardID: string}) {
+function SuccessReportCardLost({cardID, isFromDomainCardDetail = false}: {cardID: string; isFromDomainCardDetail?: boolean}) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
@@ -20,7 +20,10 @@ function SuccessReportCardLost({cardID}: {cardID: string}) {
illustration={illustrations.CardReplacementSuccess}
shouldShowButton
onButtonPress={() => {
- Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAIN_CARD.getRoute(cardID), {forceReplace: true});
+ // Going back with compareParams: false collapses the flow onto the deleted card route and
+ // replaces its cardID with the replacement card instead of a stale/NotFound route.
+ const cardDetailRoute = isFromDomainCardDetail ? ROUTES.SETTINGS_DOMAIN_CARD_DETAIL.getRoute(cardID) : ROUTES.SETTINGS_WALLET_DOMAIN_CARD.getRoute(cardID);
+ Navigation.goBack(cardDetailRoute, {compareParams: false});
}}
buttonText={translate('common.buttonConfirm')}
containerStyle={styles.h100}