diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 05b228c73c76..98e78cf919cf 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -181,9 +181,7 @@ function IOURequestStepDistance({ */ const navigateToWaypointEditPage = useCallback( (index: number) => { - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_WAYPOINT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, report?.reportID, index.toString(), Navigation.getActiveRouteWithoutParams()), - ); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_WAYPOINT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, report?.reportID, index.toString(), Navigation.getActiveRoute())); }, [action, transactionID, report?.reportID], ); diff --git a/src/pages/iou/request/step/IOURequestStepWaypoint.tsx b/src/pages/iou/request/step/IOURequestStepWaypoint.tsx index 0ba61d92071d..d305e69c9615 100644 --- a/src/pages/iou/request/step/IOURequestStepWaypoint.tsx +++ b/src/pages/iou/request/step/IOURequestStepWaypoint.tsx @@ -88,6 +88,14 @@ function IOURequestStepWaypoint({ isFocused && (Number.isNaN(parsedWaypointIndex) || parsedWaypointIndex < 0 || parsedWaypointIndex > waypointCount || (filledWaypointCount < 2 && parsedWaypointIndex >= waypointCount)); + const goBack = () => { + if (backTo) { + Navigation.goBack(backTo); + return; + } + Navigation.goBack(ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + }; + const validate = (values: FormOnyxValues<'waypointForm'>): Partial> => { const errors = {}; const waypointValue = values[`waypoint${pageIndex}`] ?? ''; @@ -127,14 +135,14 @@ function IOURequestStepWaypoint({ } // Other flows will be handled by selecting a waypoint with selectWaypoint as this is mainly for the offline flow - Navigation.goBack(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(action, iouType, transactionID, reportID)); + goBack(); }; const deleteStopAndHideModal = () => { Transaction.removeWaypoint(transaction, pageIndex, action === CONST.IOU.ACTION.CREATE); setRestoreFocusType(CONST.MODAL.RESTORE_FOCUS_TYPE.DELETE); setIsDeleteStopModalOpen(false); - Navigation.goBack(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(action, iouType, transactionID, reportID)); + goBack(); }; const selectWaypoint = (values: Waypoint) => { @@ -147,11 +155,7 @@ function IOURequestStepWaypoint({ }; Transaction.saveWaypoint(transactionID, pageIndex, waypoint, action === CONST.IOU.ACTION.CREATE); - if (backTo) { - Navigation.goBack(backTo); - return; - } - Navigation.goBack(ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + goBack(); }; return ( @@ -165,9 +169,7 @@ function IOURequestStepWaypoint({ { - Navigation.goBack(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(action, iouType, transactionID, reportID)); - }} + onBackButtonPress={goBack} shouldShowThreeDotsButton={shouldShowThreeDotsButton} shouldSetModalVisibility={false} threeDotsAnchorPosition={styles.threeDotsPopoverOffset(windowWidth)}