From d1fd0869ad469a7f4eb71b28e8a407e5682bf9d8 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 26 Aug 2024 17:37:53 +0800 Subject: [PATCH 01/18] add backTo to many pages so it shows the correct screen below the RHP overlay --- src/ROUTES.ts | 38 ++++-- src/components/AvatarWithDisplayName.tsx | 11 +- src/components/MoneyReportHeader.tsx | 4 +- src/components/MoneyRequestHeader.tsx | 4 +- src/components/PromotedActionsBar.tsx | 8 +- .../ReportActionItem/MoneyReportView.tsx | 11 +- .../ReportActionItem/MoneyRequestView.tsx | 113 ++++++++++++++++-- src/libs/HeaderUtils.ts | 4 +- src/libs/Navigation/Navigation.ts | 9 ++ src/libs/Navigation/linkingConfig/config.ts | 12 +- src/libs/Navigation/types.ts | 43 +++++-- src/libs/ReportUtils.ts | 4 +- src/libs/actions/Task.ts | 11 +- src/pages/EditReportFieldPage.tsx | 33 +++-- src/pages/ReportDetailsPage.tsx | 19 +-- src/pages/ReportParticipantsPage.tsx | 10 +- src/pages/ShareCodePage.tsx | 9 +- .../home/report/ReportActionItemSingle.tsx | 2 +- .../report/ReportDetailsShareCodePage.tsx | 10 +- .../home/report/withReportOrNotFound.tsx | 14 ++- .../settings/Report/ReportSettingsPage.tsx | 4 +- src/pages/tasks/NewTaskDescriptionPage.tsx | 8 +- src/pages/tasks/NewTaskDetailsPage.tsx | 8 +- src/pages/tasks/NewTaskPage.tsx | 12 +- src/pages/tasks/NewTaskTitlePage.tsx | 8 +- src/pages/tasks/TaskAssigneeSelectorModal.tsx | 7 +- .../TaskShareDestinationSelectorModal.tsx | 4 +- 27 files changed, 304 insertions(+), 116 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 47a2ad76209e..2364e7a384f7 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -265,11 +265,11 @@ const ROUTES = { }, EDIT_REPORT_FIELD_REQUEST: { route: 'r/:reportID/edit/policyField/:policyID/:fieldID', - getRoute: (reportID: string, policyID: string, fieldID: string) => `r/${reportID}/edit/policyField/${policyID}/${fieldID}` as const, + getRoute: (reportID: string, policyID: string, fieldID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/edit/policyField/${policyID}/${fieldID}` as const, backTo), }, REPORT_WITH_ID_DETAILS_SHARE_CODE: { route: 'r/:reportID/details/shareCode', - getRoute: (reportID: string) => `r/${reportID}/details/shareCode` as const, + getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/details/shareCode` as const, backTo), }, ATTACHMENTS: { route: 'attachment', @@ -278,7 +278,7 @@ const ROUTES = { }, REPORT_PARTICIPANTS: { route: 'r/:reportID/participants', - getRoute: (reportID: string) => `r/${reportID}/participants` as const, + getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/participants` as const, backTo), }, REPORT_PARTICIPANTS_INVITE: { route: 'r/:reportID/participants/invite', @@ -302,7 +302,7 @@ const ROUTES = { }, REPORT_SETTINGS: { route: 'r/:reportID/settings', - getRoute: (reportID: string) => `r/${reportID}/settings` as const, + getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/settings` as const, backTo), }, REPORT_SETTINGS_NAME: { route: 'r/:reportID/settings/name', @@ -508,12 +508,27 @@ const ROUTES = { IOU_SEND_ADD_DEBIT_CARD: 'pay/new/add-debit-card', IOU_SEND_ENABLE_PAYMENTS: 'pay/new/enable-payments', - NEW_TASK: 'new/task', - NEW_TASK_ASSIGNEE: 'new/task/assignee', + NEW_TASK: { + route: 'new/task', + getRoute: (backTo?: string) => getUrlWithBackToParam('new/task', backTo), + }, + NEW_TASK_ASSIGNEE: { + route: 'new/task/assignee', + getRoute: (backTo?: string) => getUrlWithBackToParam('new/task/assignee', backTo), + }, NEW_TASK_SHARE_DESTINATION: 'new/task/share-destination', - NEW_TASK_DETAILS: 'new/task/details', - NEW_TASK_TITLE: 'new/task/title', - NEW_TASK_DESCRIPTION: 'new/task/description', + NEW_TASK_DETAILS: { + route: 'new/task/details', + getRoute: (backTo?: string) => getUrlWithBackToParam('new/task/details', backTo), + }, + NEW_TASK_TITLE: { + route: 'new/task/title', + getRoute: (backTo?: string) => getUrlWithBackToParam('new/task/title', backTo), + }, + NEW_TASK_DESCRIPTION: { + route: 'new/task/description', + getRoute: (backTo?: string) => getUrlWithBackToParam('new/task/description', backTo), + }, TEACHERS_UNITE: 'settings/teachersunite', I_KNOW_A_TEACHER: 'settings/teachersunite/i-know-a-teacher', @@ -969,7 +984,10 @@ const ROUTES = { route: 'referral/:contentType', getRoute: (contentType: string, backTo?: string) => getUrlWithBackToParam(`referral/${contentType}`, backTo), }, - PROCESS_MONEY_REQUEST_HOLD: 'hold-expense-educational', + PROCESS_MONEY_REQUEST_HOLD: { + route: 'hold-expense-educational', + getRoute: (backTo?: string) => getUrlWithBackToParam('hold-expense-educational', backTo), + }, TRAVEL_MY_TRIPS: 'travel', TRAVEL_TCS: 'travel/terms', TRACK_TRAINING_MODAL: 'track-training', diff --git a/src/components/AvatarWithDisplayName.tsx b/src/components/AvatarWithDisplayName.tsx index 2ccdd47c3205..adb3775cadd4 100644 --- a/src/components/AvatarWithDisplayName.tsx +++ b/src/components/AvatarWithDisplayName.tsx @@ -79,10 +79,15 @@ function AvatarWithDisplayName({ actorAccountID.current = parentReportAction?.actorAccountID ?? -1; }, [parentReportActions, report]); + const goToDetailsPage = useCallback(() => { + ReportUtils.navigateToDetailsPage(report, Navigation.getReportRHPActiveRoute()); + }, [report]); + const showActorDetails = useCallback(() => { // We should navigate to the details page if the report is a IOU/expense report if (shouldEnableDetailPageNavigation) { - return ReportUtils.navigateToDetailsPage(report); + goToDetailsPage(); + return; } if (ReportUtils.isExpenseReport(report) && report?.ownerAccountID) { @@ -107,7 +112,7 @@ function AvatarWithDisplayName({ // Report detail route is added as fallback but based on the current implementation this route won't be executed Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)); } - }, [report, shouldEnableDetailPageNavigation]); + }, [report, shouldEnableDetailPageNavigation, goToDetailsPage]); const headerView = ( @@ -172,7 +177,7 @@ function AvatarWithDisplayName({ return ( ReportUtils.navigateToDetailsPage(report)} + onPress={goToDetailsPage} style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]} accessibilityLabel={title} role={CONST.ROLE.BUTTON} diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index ee3929292cd3..b349dbe0fa81 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -249,11 +249,11 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea } if (isSmallScreenWidth) { - if (Navigation.getActiveRoute().slice(1) === ROUTES.PROCESS_MONEY_REQUEST_HOLD) { + if (Navigation.getActiveRoute().slice(1) === ROUTES.PROCESS_MONEY_REQUEST_HOLD.route) { Navigation.goBack(); } } else { - Navigation.navigate(ROUTES.PROCESS_MONEY_REQUEST_HOLD); + Navigation.navigate(ROUTES.PROCESS_MONEY_REQUEST_HOLD.getRoute(Navigation.getReportRHPActiveRoute())); } }, [isSmallScreenWidth, shouldShowHoldMenu]); diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index d7844a1f5e93..3d06deea9627 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -109,11 +109,11 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow } if (isSmallScreenWidth) { - if (Navigation.getActiveRoute().slice(1) === ROUTES.PROCESS_MONEY_REQUEST_HOLD) { + if (Navigation.getActiveRoute().slice(1) === ROUTES.PROCESS_MONEY_REQUEST_HOLD.route) { Navigation.goBack(); } } else { - Navigation.navigate(ROUTES.PROCESS_MONEY_REQUEST_HOLD); + Navigation.navigate(ROUTES.PROCESS_MONEY_REQUEST_HOLD.getRoute(Navigation.getReportRHPActiveRoute())); } }, [isSmallScreenWidth, shouldShowHoldMenu]); diff --git a/src/components/PromotedActionsBar.tsx b/src/components/PromotedActionsBar.tsx index b0309d702f9a..6bae83d170da 100644 --- a/src/components/PromotedActionsBar.tsx +++ b/src/components/PromotedActionsBar.tsx @@ -24,9 +24,11 @@ type PromotedAction = { key: string; } & ThreeDotsMenuItem; -type BasePromotedActions = typeof CONST.PROMOTED_ACTIONS.PIN | typeof CONST.PROMOTED_ACTIONS.SHARE | typeof CONST.PROMOTED_ACTIONS.JOIN; +type BasePromotedActions = typeof CONST.PROMOTED_ACTIONS.PIN | typeof CONST.PROMOTED_ACTIONS.JOIN; type PromotedActionsType = Record PromotedAction> & { + share: (report: OnyxReport, backTo?: string) => PromotedAction; +} & { message: (params: {reportID?: string; accountID?: number; login?: string}) => PromotedAction; } & { hold: (params: {isTextHold: boolean; reportAction: ReportAction | undefined; reportID?: string}) => PromotedAction; @@ -37,9 +39,9 @@ const PromotedActions = { key: CONST.PROMOTED_ACTIONS.PIN, ...HeaderUtils.getPinMenuItem(report), }), - share: (report) => ({ + share: (report, backTo) => ({ key: CONST.PROMOTED_ACTIONS.SHARE, - ...HeaderUtils.getShareMenuItem(report), + ...HeaderUtils.getShareMenuItem(report, backTo), }), join: (report) => ({ key: CONST.PROMOTED_ACTIONS.JOIN, diff --git a/src/components/ReportActionItem/MoneyReportView.tsx b/src/components/ReportActionItem/MoneyReportView.tsx index fbf03821fa16..26e7fd8a5d52 100644 --- a/src/components/ReportActionItem/MoneyReportView.tsx +++ b/src/components/ReportActionItem/MoneyReportView.tsx @@ -108,7 +108,16 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo Navigation.navigate(ROUTES.EDIT_REPORT_FIELD_REQUEST.getRoute(report.reportID, report.policyID ?? '-1', reportField.fieldID))} + onPress={() => + Navigation.navigate( + ROUTES.EDIT_REPORT_FIELD_REQUEST.getRoute( + report.reportID, + report.policyID ?? '-1', + reportField.fieldID, + Navigation.getReportRHPActiveRoute(), + ), + ) + } shouldShowRightIcon disabled={isFieldDisabled} wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 4a76f33de346..ebc78ffe84bc 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -348,7 +348,15 @@ function MoneyRequestView({ shouldShowRightIcon={canEditDistance} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1')) + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute( + CONST.IOU.ACTION.EDIT, + iouType, + transaction?.transactionID ?? '-1', + report?.reportID ?? '-1', + Navigation.getReportRHPActiveRoute(), + ), + ) } /> @@ -360,7 +368,15 @@ function MoneyRequestView({ shouldShowRightIcon={canEditDistanceRate} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE_RATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1')) + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_DISTANCE_RATE.getRoute( + CONST.IOU.ACTION.EDIT, + iouType, + transaction?.transactionID ?? '-1', + report?.reportID ?? '-1', + Navigation.getReportRHPActiveRoute(), + ), + ) } /> @@ -373,7 +389,17 @@ function MoneyRequestView({ interactive={canEditDistance} shouldShowRightIcon={canEditDistance} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1'))} + onPress={() => + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute( + CONST.IOU.ACTION.EDIT, + iouType, + transaction?.transactionID ?? '-1', + report?.reportID ?? '-1', + Navigation.getReportRHPActiveRoute(), + ), + ) + } /> ); @@ -432,7 +458,16 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.EDIT, iouType, orderWeight, transaction?.transactionID ?? '', report?.reportID ?? '-1')) + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_TAG.getRoute( + CONST.IOU.ACTION.EDIT, + iouType, + orderWeight, + transaction?.transactionID ?? '', + report?.reportID ?? '-1', + Navigation.getReportRHPActiveRoute(), + ), + ) } brickRoadIndicator={tagError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={tagError} @@ -509,7 +544,7 @@ function MoneyRequestView({ iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1', - Navigation.getActiveRouteWithoutParams(), + Navigation.getReportRHPActiveRoute(), ), ) } @@ -527,7 +562,15 @@ function MoneyRequestView({ interactive={canEditAmount} shouldShowRightIcon={canEditAmount} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1')) + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute( + CONST.IOU.ACTION.EDIT, + iouType, + transaction?.transactionID ?? '-1', + report?.reportID ?? '-1', + Navigation.getReportRHPActiveRoute(), + ), + ) } brickRoadIndicator={getErrorForField('amount') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('amount')} @@ -542,7 +585,15 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1')) + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute( + CONST.IOU.ACTION.EDIT, + iouType, + transaction?.transactionID ?? '-1', + report?.reportID ?? '-1', + Navigation.getReportRHPActiveRoute(), + ), + ) } wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} brickRoadIndicator={getErrorForField('comment') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} @@ -561,7 +612,15 @@ function MoneyRequestView({ shouldShowRightIcon={canEditMerchant} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1')) + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute( + CONST.IOU.ACTION.EDIT, + iouType, + transaction?.transactionID ?? '-1', + report?.reportID ?? '-1', + Navigation.getReportRHPActiveRoute(), + ), + ) } wrapperStyle={[styles.taskDescriptionMenuItem]} brickRoadIndicator={getErrorForField('merchant') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} @@ -578,7 +637,15 @@ function MoneyRequestView({ shouldShowRightIcon={canEditDate} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1' ?? '-1')) + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_DATE.getRoute( + CONST.IOU.ACTION.EDIT, + iouType, + transaction?.transactionID ?? '-1', + report?.reportID ?? '-1' ?? '-1', + Navigation.getReportRHPActiveRoute(), + ), + ) } brickRoadIndicator={getErrorForField('date') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('date')} @@ -593,7 +660,15 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1')) + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( + CONST.IOU.ACTION.EDIT, + iouType, + transaction?.transactionID ?? '-1', + report?.reportID ?? '-1', + Navigation.getReportRHPActiveRoute(), + ), + ) } brickRoadIndicator={getErrorForField('category') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('category')} @@ -620,7 +695,15 @@ function MoneyRequestView({ shouldShowRightIcon={canEditTaxFields} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1')) + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute( + CONST.IOU.ACTION.EDIT, + iouType, + transaction?.transactionID ?? '-1', + report?.reportID ?? '-1', + Navigation.getReportRHPActiveRoute(), + ), + ) } brickRoadIndicator={getErrorForField('tax') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('tax')} @@ -637,7 +720,13 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1'), + ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute( + CONST.IOU.ACTION.EDIT, + iouType, + transaction?.transactionID ?? '-1', + report?.reportID ?? '-1', + Navigation.getReportRHPActiveRoute(), + ), ) } /> diff --git a/src/libs/HeaderUtils.ts b/src/libs/HeaderUtils.ts index 03c582d6b16b..b31d59804c51 100644 --- a/src/libs/HeaderUtils.ts +++ b/src/libs/HeaderUtils.ts @@ -17,11 +17,11 @@ function getPinMenuItem(report: OnyxReport): ThreeDotsMenuItem { }; } -function getShareMenuItem(report: OnyxReport): ThreeDotsMenuItem { +function getShareMenuItem(report: OnyxReport, backTo?: string): ThreeDotsMenuItem { return { icon: Expensicons.QrCode, text: Localize.translateLocal('common.share'), - onSelected: () => Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS_SHARE_CODE.getRoute(report?.reportID ?? '')), + onSelected: () => Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS_SHARE_CODE.getRoute(report?.reportID ?? '', backTo)), }; } diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index 4bd86503fd2b..72de445dbe42 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -20,6 +20,7 @@ import getTopmostBottomTabRoute from './getTopmostBottomTabRoute'; import getTopmostCentralPaneRoute from './getTopmostCentralPaneRoute'; import originalGetTopmostReportActionId from './getTopmostReportActionID'; import originalGetTopmostReportId from './getTopmostReportId'; +import isReportOpenInRHP from './isReportOpenInRHP'; import linkingConfig from './linkingConfig'; import getMatchingBottomTabRouteForState from './linkingConfig/getMatchingBottomTabRouteForState'; import linkTo from './linkTo'; @@ -153,6 +154,13 @@ function getActiveRoute(): string { return ''; } +function getReportRHPActiveRoute(): string { + if (isReportOpenInRHP(navigationRef.getRootState())) { + return getActiveRoute(); + } + return ''; +} + /** * Check whether the passed route is currently Active or not. * @@ -415,6 +423,7 @@ export default { isActiveRoute, getActiveRoute, getActiveRouteWithoutParams, + getReportRHPActiveRoute, closeAndNavigate, goBack, isNavigationReady, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 4d3f19984b8f..f4528b4ed9a6 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -833,12 +833,12 @@ const config: LinkingOptions['config'] = { }, [SCREENS.RIGHT_MODAL.NEW_TASK]: { screens: { - [SCREENS.NEW_TASK.ROOT]: ROUTES.NEW_TASK, - [SCREENS.NEW_TASK.TASK_ASSIGNEE_SELECTOR]: ROUTES.NEW_TASK_ASSIGNEE, + [SCREENS.NEW_TASK.ROOT]: ROUTES.NEW_TASK.route, + [SCREENS.NEW_TASK.TASK_ASSIGNEE_SELECTOR]: ROUTES.NEW_TASK_ASSIGNEE.route, [SCREENS.NEW_TASK.TASK_SHARE_DESTINATION_SELECTOR]: ROUTES.NEW_TASK_SHARE_DESTINATION, - [SCREENS.NEW_TASK.DETAILS]: ROUTES.NEW_TASK_DETAILS, - [SCREENS.NEW_TASK.TITLE]: ROUTES.NEW_TASK_TITLE, - [SCREENS.NEW_TASK.DESCRIPTION]: ROUTES.NEW_TASK_DESCRIPTION, + [SCREENS.NEW_TASK.DETAILS]: ROUTES.NEW_TASK_DETAILS.route, + [SCREENS.NEW_TASK.TITLE]: ROUTES.NEW_TASK_TITLE.route, + [SCREENS.NEW_TASK.DESCRIPTION]: ROUTES.NEW_TASK_DESCRIPTION.route, }, }, [SCREENS.RIGHT_MODAL.TEACHERS_UNITE]: { @@ -1006,7 +1006,7 @@ const config: LinkingOptions['config'] = { }, [SCREENS.RIGHT_MODAL.PROCESS_MONEY_REQUEST_HOLD]: { screens: { - [SCREENS.PROCESS_MONEY_REQUEST_HOLD_ROOT]: ROUTES.PROCESS_MONEY_REQUEST_HOLD, + [SCREENS.PROCESS_MONEY_REQUEST_HOLD_ROOT]: ROUTES.PROCESS_MONEY_REQUEST_HOLD.route, }, }, [SCREENS.RIGHT_MODAL.TRAVEL]: { diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index ceb62f1dac1c..8ed751ac9245 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -728,9 +728,13 @@ type ProfileNavigatorParamList = { }; type ReportDetailsNavigatorParamList = { - [SCREENS.REPORT_DETAILS.ROOT]: undefined; + [SCREENS.REPORT_DETAILS.ROOT]: { + reportID: string; + backTo?: Routes; + }; [SCREENS.REPORT_DETAILS.SHARE_CODE]: { reportID: string; + backTo?: Routes; }; [SCREENS.REPORT_DETAILS.EXPORT]: { reportID: string; @@ -740,7 +744,10 @@ type ReportDetailsNavigatorParamList = { }; type ReportSettingsNavigatorParamList = { - [SCREENS.REPORT_SETTINGS.ROOT]: {reportID: string}; + [SCREENS.REPORT_SETTINGS.ROOT]: { + reportID: string; + backTo?: Routes; + }; [SCREENS.REPORT_SETTINGS.NAME]: {reportID: string}; [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: {reportID: string}; [SCREENS.REPORT_SETTINGS.WRITE_CAPABILITY]: {reportID: string}; @@ -754,7 +761,10 @@ type ReportDescriptionNavigatorParamList = { }; type ParticipantsNavigatorParamList = { - [SCREENS.REPORT_PARTICIPANTS.ROOT]: {reportID: string}; + [SCREENS.REPORT_PARTICIPANTS.ROOT]: { + reportID: string; + backTo?: Routes; + }; [SCREENS.REPORT_PARTICIPANTS.INVITE]: {reportID: string}; [SCREENS.REPORT_PARTICIPANTS.DETAILS]: { reportID: string; @@ -938,12 +948,22 @@ type MoneyRequestNavigatorParamList = { }; type NewTaskNavigatorParamList = { - [SCREENS.NEW_TASK.ROOT]: undefined; - [SCREENS.NEW_TASK.TASK_ASSIGNEE_SELECTOR]: undefined; + [SCREENS.NEW_TASK.ROOT]: { + backTo?: Routes; + }; + [SCREENS.NEW_TASK.TASK_ASSIGNEE_SELECTOR]: { + backTo?: Routes; + }; [SCREENS.NEW_TASK.TASK_SHARE_DESTINATION_SELECTOR]: undefined; - [SCREENS.NEW_TASK.DETAILS]: undefined; - [SCREENS.NEW_TASK.TITLE]: undefined; - [SCREENS.NEW_TASK.DESCRIPTION]: undefined; + [SCREENS.NEW_TASK.DETAILS]: { + backTo?: Routes; + }; + [SCREENS.NEW_TASK.TITLE]: { + backTo?: Routes; + }; + [SCREENS.NEW_TASK.DESCRIPTION]: { + backTo?: Routes; + }; }; type TeachersUniteNavigatorParamList = { @@ -1005,7 +1025,12 @@ type FlagCommentNavigatorParamList = { }; type EditRequestNavigatorParamList = { - [SCREENS.EDIT_REQUEST.REPORT_FIELD]: undefined; + [SCREENS.EDIT_REQUEST.REPORT_FIELD]: { + fieldID: string; + reportID: string; + policyID: string; + backTo?: Routes; + }; }; type SignInNavigatorParamList = { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 38b73ffc2057..034f00d4abc7 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3872,7 +3872,7 @@ function getParentNavigationSubtitle(report: OnyxEntry, invoiceReceiverP /** * Navigate to the details page of a given report */ -function navigateToDetailsPage(report: OnyxEntry) { +function navigateToDetailsPage(report: OnyxEntry, backTo?: string) { const isSelfDMReport = isSelfDM(report); const isOneOnOneChatReport = isOneOnOneChat(report); const participantAccountID = getParticipantsAccountIDsForDisplay(report); @@ -3883,7 +3883,7 @@ function navigateToDetailsPage(report: OnyxEntry) { } if (report?.reportID) { - Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID, backTo)); } } diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 001245717e12..f92267ee3eef 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -18,6 +18,7 @@ import playSound, {SOUNDS} from '@libs/Sound'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import type {Route} from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; import type {Icon} from '@src/types/onyx/OnyxCommon'; import type {ReportActions} from '@src/types/onyx/ReportAction'; @@ -836,7 +837,7 @@ function clearOutTaskInfoAndNavigate(reportID?: string, chatReport?: OnyxEntry) { /** * Closes the current open task modal and clears out the task info from the store. */ -function dismissModalAndClearOutTaskInfo() { - Navigation.closeRHPFlow(); +function dismissModalAndClearOutTaskInfo(backTo?: Route) { + if (backTo) { + Navigation.goBack(backTo); + } else { + Navigation.closeRHPFlow(); + } clearOutTaskInfo(); } diff --git a/src/pages/EditReportFieldPage.tsx b/src/pages/EditReportFieldPage.tsx index 9922eeb2a430..206756a2a07f 100644 --- a/src/pages/EditReportFieldPage.tsx +++ b/src/pages/EditReportFieldPage.tsx @@ -1,3 +1,4 @@ +import type {StackScreenProps} from '@react-navigation/stack'; import {Str} from 'expensify-common'; import React, {useState} from 'react'; import {withOnyx} from 'react-native-onyx'; @@ -14,9 +15,12 @@ import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import isSearchTopmostCentralPane from '@libs/Navigation/isSearchTopmostCentralPane'; import Navigation from '@libs/Navigation/Navigation'; +import type {EditRequestNavigatorParamList} from '@libs/Navigation/types'; import * as ReportUtils from '@libs/ReportUtils'; import * as ReportActions from '@src/libs/actions/Report'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; +import type SCREENS from '@src/SCREENS'; import type {Policy, Report} from '@src/types/onyx'; import EditReportFieldDate from './EditReportFieldDate'; import EditReportFieldDropdown from './EditReportFieldDropdown'; @@ -30,26 +34,12 @@ type EditReportFieldPageOnyxProps = { policy: OnyxEntry; }; -type EditReportFieldPageProps = EditReportFieldPageOnyxProps & { - /** Route from navigation */ - route: { - /** Params from the route */ - params: { - /** Which field we are editing */ - fieldID: string; - - /** reportID for the expense report */ - reportID: string; - - /** policyID for the expense report */ - policyID: string; - }; - }; -}; +type EditReportFieldPageProps = EditReportFieldPageOnyxProps & StackScreenProps; function EditReportFieldPage({route, policy, report}: EditReportFieldPageProps) { const {windowWidth} = useWindowDimensions(); const styles = useThemeStyles(); + const backTo = route.params.backTo; const fieldKey = ReportUtils.getReportFieldKey(route.params.fieldID); const reportField = report?.fieldList?.[fieldKey] ?? policy?.fieldList?.[fieldKey]; const isDisabled = ReportUtils.isReportFieldDisabled(report, reportField, policy); @@ -74,11 +64,19 @@ function EditReportFieldPage({route, policy, report}: EditReportFieldPageProps) ); } + const goBack = () => { + if (isReportFieldTitle) { + Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID, backTo)); + return; + } + Navigation.goBack(backTo); + }; + const handleReportFieldChange = (form: FormOnyxValues) => { const value = form[fieldKey]; if (isReportFieldTitle) { ReportActions.updateReportName(report.reportID, value, report.reportName ?? ''); - Navigation.goBack(); + goBack(); } else { ReportActions.updateReportField(report.reportID, {...reportField, value: value === '' ? null : value}, reportField); Navigation.dismissModal(isSearchTopmostCentralPane() ? undefined : report?.reportID); @@ -114,6 +112,7 @@ function EditReportFieldPage({route, policy, report}: EditReportFieldPageProps) threeDotsMenuItems={menuItems} shouldShowThreeDotsButton={!!menuItems?.length} threeDotsAnchorPosition={styles.threeDotsPopoverOffsetNoCloseButton(windowWidth)} + onBackButtonPress={goBack} /> ; -function ReportDetailsPage({policies, report, session, personalDetails}: ReportDetailsPageProps) { +function ReportDetailsPage({policies, report, session, personalDetails, route}: ReportDetailsPageProps) { const {translate} = useLocalize(); const {isOffline} = useNetwork(); const styles = useThemeStyles(); + const backTo = route.params.backTo; // The app would crash due to subscribing to the entire report collection if parentReportID is an empty string. So we should have a fallback ID here. /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ @@ -316,7 +317,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD if (shouldOpenRoomMembersPage) { Navigation.navigate(ROUTES.ROOM_MEMBERS.getRoute(report?.reportID ?? '-1')); } else { - Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(report?.reportID ?? '-1')); + Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(report?.reportID ?? '-1', backTo)); } }, }); @@ -341,7 +342,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD isAnonymousAction: false, shouldShowRightIcon: true, action: () => { - Navigation.navigate(ROUTES.REPORT_SETTINGS.getRoute(report?.reportID ?? '-1')); + Navigation.navigate(ROUTES.REPORT_SETTINGS.getRoute(report?.reportID ?? '-1', backTo)); }, }); } @@ -456,6 +457,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD canUnapproveRequest, unapproveExpenseReportOrShowModal, isExpenseReport, + backTo, ]); const displayNamesWithTooltips = useMemo(() => { @@ -561,10 +563,10 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD result.push(PromotedActions.pin(report)); } - result.push(PromotedActions.share(report)); + result.push(PromotedActions.share(report, backTo)); return result; - }, [report, moneyRequestAction, canJoin, isExpenseReport, shouldShowHoldAction, canHoldUnholdReportAction.canHoldRequest, transactionThreadReportID]); + }, [report, moneyRequestAction, canJoin, isExpenseReport, shouldShowHoldAction, canHoldUnholdReportAction.canHoldRequest, transactionThreadReportID, backTo]); const nameSectionExpenseIOU = ( @@ -671,7 +673,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD titleStyle={styles.newKansasLarge} shouldCheckActionAllowedOnPress={false} description={Str.UCFirst(titleField.name)} - onPress={() => Navigation.navigate(ROUTES.EDIT_REPORT_FIELD_REQUEST.getRoute(report.reportID, report.policyID ?? '-1', titleField.fieldID ?? '-1'))} + onPress={() => Navigation.navigate(ROUTES.EDIT_REPORT_FIELD_REQUEST.getRoute(report.reportID, report.policyID ?? '-1', titleField.fieldID ?? '-1', backTo))} furtherDetailsComponent={nameSectionFurtherDetailsContent} /> @@ -706,7 +708,10 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD return ( - + Navigation.goBack(backTo)} + /> {renderedAvatar} diff --git a/src/pages/ReportParticipantsPage.tsx b/src/pages/ReportParticipantsPage.tsx index 9815177da615..e35f6763325c 100755 --- a/src/pages/ReportParticipantsPage.tsx +++ b/src/pages/ReportParticipantsPage.tsx @@ -1,4 +1,5 @@ import {useIsFocused} from '@react-navigation/native'; +import type {StackScreenProps} from '@react-navigation/stack'; import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {InteractionManager, View} from 'react-native'; import type {TextInput} from 'react-native'; @@ -24,17 +25,20 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode'; import * as Report from '@libs/actions/Report'; import Navigation from '@libs/Navigation/Navigation'; +import type {ParticipantsNavigatorParamList} from '@libs/Navigation/types'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as ReportUtils from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import type SCREENS from '@src/SCREENS'; import type {WithReportOrNotFoundProps} from './home/report/withReportOrNotFound'; import withReportOrNotFound from './home/report/withReportOrNotFound'; type MemberOption = Omit & {accountID: number}; -function ReportParticipantsPage({report}: WithReportOrNotFoundProps) { +type ReportParticipantsPageProps = WithReportOrNotFoundProps & StackScreenProps; +function ReportParticipantsPage({report, route}: ReportParticipantsPageProps) { const [selectedMembers, setSelectedMembers] = useState([]); const [removeMembersConfirmModalVisible, setRemoveMembersConfirmModalVisible] = useState(false); const {translate, formatPhoneNumber} = useLocalize(); @@ -287,7 +291,7 @@ function ReportParticipantsPage({report}: WithReportOrNotFoundProps) { Navigation.navigate(ROUTES.REPORT_PARTICIPANTS_DETAILS.getRoute(report.reportID, item.accountID)); return; } - Navigation.navigate(ROUTES.PROFILE.getRoute(item.accountID)); + Navigation.navigate(ROUTES.PROFILE.getRoute(item.accountID, Navigation.getActiveRoute())); }, [report, isCurrentUserAdmin, isGroupChat], ); @@ -324,7 +328,7 @@ function ReportParticipantsPage({report}: WithReportOrNotFoundProps) { } if (report) { - Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)); + Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID, route.params.backTo)); } }} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS} diff --git a/src/pages/ShareCodePage.tsx b/src/pages/ShareCodePage.tsx index e11e99a6e852..18f6c5960b5e 100644 --- a/src/pages/ShareCodePage.tsx +++ b/src/pages/ShareCodePage.tsx @@ -19,6 +19,7 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import Clipboard from '@libs/Clipboard'; import Navigation from '@libs/Navigation/Navigation'; +import type {BackToParams} from '@libs/Navigation/types'; import * as ReportUtils from '@libs/ReportUtils'; import * as Url from '@libs/Url'; import * as UserUtils from '@libs/UserUtils'; @@ -34,7 +35,7 @@ type ShareCodePageOnyxProps = { policy?: OnyxEntry; }; -type ShareCodePageProps = ShareCodePageOnyxProps; +type ShareCodePageProps = ShareCodePageOnyxProps & BackToParams; /** * When sharing a policy (workspace) only return user avatar that is user defined. Default ws avatars have separate logic. @@ -53,7 +54,7 @@ function getLogoForWorkspace(report: OnyxEntry, policy?: OnyxEntry Navigation.goBack(isReport ? ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID) : undefined)} + onBackButtonPress={() => Navigation.goBack(isReport ? ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID, backTo) : undefined)} shouldShowBackButton /> @@ -146,7 +147,7 @@ function ShareCodePage({report, policy}: ShareCodePageProps) { Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE, Navigation.getActiveRouteWithoutParams()))} + onPress={() => Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE, Navigation.getActiveRoute()))} shouldShowRightIcon /> diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 95a7332f0606..49fc6f6dba43 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -58,7 +58,7 @@ type ReportActionItemSingleProps = Partial & { }; const showUserDetails = (accountID: string) => { - Navigation.navigate(ROUTES.PROFILE.getRoute(accountID)); + Navigation.navigate(ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute())); }; const showWorkspaceDetails = (reportID: string) => { diff --git a/src/pages/home/report/ReportDetailsShareCodePage.tsx b/src/pages/home/report/ReportDetailsShareCodePage.tsx index efee188d0beb..4caa29209fa9 100644 --- a/src/pages/home/report/ReportDetailsShareCodePage.tsx +++ b/src/pages/home/report/ReportDetailsShareCodePage.tsx @@ -1,10 +1,13 @@ +import type {StackScreenProps} from '@react-navigation/stack'; import React from 'react'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; +import type {ReportDetailsNavigatorParamList} from '@libs/Navigation/types'; import * as ReportUtils from '@libs/ReportUtils'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; import ShareCodePage from '@pages/ShareCodePage'; import ONYXKEYS from '@src/ONYXKEYS'; +import type SCREENS from '@src/SCREENS'; import type {Policy} from '@src/types/onyx'; import type {WithReportOrNotFoundProps} from './withReportOrNotFound'; import withReportOrNotFound from './withReportOrNotFound'; @@ -13,14 +16,17 @@ type ReportDetailsShareCodePageOnyxProps = { policy: OnyxEntry; }; -type ReportDetailsShareCodePageProps = ReportDetailsShareCodePageOnyxProps & WithReportOrNotFoundProps; +type ReportDetailsShareCodePageProps = ReportDetailsShareCodePageOnyxProps & + WithReportOrNotFoundProps & + StackScreenProps; -function ReportDetailsShareCodePage({report, policy}: ReportDetailsShareCodePageProps) { +function ReportDetailsShareCodePage({report, policy, route}: ReportDetailsShareCodePageProps) { if (ReportUtils.isSelfDM(report)) { return ; } return ( diff --git a/src/pages/home/report/withReportOrNotFound.tsx b/src/pages/home/report/withReportOrNotFound.tsx index 7f6165a031ee..58381e4f0764 100644 --- a/src/pages/home/report/withReportOrNotFound.tsx +++ b/src/pages/home/report/withReportOrNotFound.tsx @@ -7,7 +7,13 @@ import {withOnyx} from 'react-native-onyx'; import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import getComponentDisplayName from '@libs/getComponentDisplayName'; import * as ReportUtils from '@libs/ReportUtils'; -import type {ParticipantsNavigatorParamList, PrivateNotesNavigatorParamList, ReportDescriptionNavigatorParamList} from '@navigation/types'; +import type { + ParticipantsNavigatorParamList, + PrivateNotesNavigatorParamList, + ReportDescriptionNavigatorParamList, + ReportDetailsNavigatorParamList, + ReportSettingsNavigatorParamList, +} from '@navigation/types'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; import * as Report from '@userActions/Report'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -36,8 +42,12 @@ type WithReportOrNotFoundProps = WithReportOrNotFoundOnyxProps & { route: | RouteProp | RouteProp + | RouteProp | RouteProp - | RouteProp; + | RouteProp + | RouteProp + | RouteProp + | RouteProp; /** The report currently being looked at */ report: OnyxTypes.Report; diff --git a/src/pages/settings/Report/ReportSettingsPage.tsx b/src/pages/settings/Report/ReportSettingsPage.tsx index 6e1ab9a61737..c541bee377a3 100644 --- a/src/pages/settings/Report/ReportSettingsPage.tsx +++ b/src/pages/settings/Report/ReportSettingsPage.tsx @@ -23,7 +23,7 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject'; type ReportSettingsPageProps = WithReportOrNotFoundProps & StackScreenProps; -function ReportSettingsPage({report, policies}: ReportSettingsPageProps) { +function ReportSettingsPage({report, policies, route}: ReportSettingsPageProps) { const reportID = report?.reportID ?? '-1'; const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -52,7 +52,7 @@ function ReportSettingsPage({report, policies}: ReportSettingsPageProps) { Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(reportID))} + onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(reportID, route.params.backTo))} /> {shouldShowNotificationPref && ( diff --git a/src/pages/tasks/NewTaskDescriptionPage.tsx b/src/pages/tasks/NewTaskDescriptionPage.tsx index f18829e8c803..6689524cd11e 100644 --- a/src/pages/tasks/NewTaskDescriptionPage.tsx +++ b/src/pages/tasks/NewTaskDescriptionPage.tsx @@ -34,14 +34,15 @@ type NewTaskDescriptionPageOnyxProps = { type NewTaskDescriptionPageProps = NewTaskDescriptionPageOnyxProps & StackScreenProps; -function NewTaskDescriptionPage({task}: NewTaskDescriptionPageProps) { +function NewTaskDescriptionPage({task, route}: NewTaskDescriptionPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const {inputCallbackRef, inputRef} = useAutoFocusInput(); + const goBack = () => Navigation.goBack(ROUTES.NEW_TASK.getRoute(route.params.backTo)); const onSubmit = (values: FormOnyxValues) => { TaskActions.setDescriptionValue(values.taskDescription); - Navigation.goBack(ROUTES.NEW_TASK); + goBack(); }; const validate = (values: FormOnyxValues): FormInputErrors => { @@ -63,8 +64,7 @@ function NewTaskDescriptionPage({task}: NewTaskDescriptionPageProps) { <> TaskActions.dismissModalAndClearOutTaskInfo()} - onBackButtonPress={() => Navigation.goBack(ROUTES.NEW_TASK)} + onBackButtonPress={goBack} /> ; -function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) { +function NewTaskDetailsPage({task, route}: NewTaskDetailsPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const [taskTitle, setTaskTitle] = useState(task?.title ?? ''); @@ -42,6 +42,7 @@ function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) { const {inputCallbackRef} = useAutoFocusInput(); + const backTo = route.params.backTo; const skipConfirmation = task?.skipConfirmation && task?.assigneeAccountID && task?.parentReportID; const buttonText = skipConfirmation ? translate('newTaskPage.assignTask') : translate('common.next'); @@ -84,7 +85,7 @@ function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) { task.assigneeChatReport, ); } else { - Navigation.navigate(ROUTES.NEW_TASK); + Navigation.navigate(ROUTES.NEW_TASK.getRoute(backTo)); } }; @@ -96,9 +97,8 @@ function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) { > TaskActions.dismissModalAndClearOutTaskInfo()} shouldShowBackButton - onBackButtonPress={() => TaskActions.dismissModalAndClearOutTaskInfo()} + onBackButtonPress={() => TaskActions.dismissModalAndClearOutTaskInfo(backTo)} /> ; -function NewTaskPage({task, reports, personalDetails}: NewTaskPageProps) { +function NewTaskPage({task, reports, personalDetails, route}: NewTaskPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const [assignee, setAssignee] = useState(); @@ -62,6 +62,7 @@ function NewTaskPage({task, reports, personalDetails}: NewTaskPageProps) { const {paddingBottom} = useStyledSafeAreaInsets(); + const backTo = route.params.backTo; const confirmButtonRef = useRef(null); const focusTimeoutRef = useRef(null); useFocusEffect( @@ -153,10 +154,9 @@ function NewTaskPage({task, reports, personalDetails}: NewTaskPageProps) { > TaskActions.dismissModalAndClearOutTaskInfo()} shouldShowBackButton onBackButtonPress={() => { - Navigation.goBack(ROUTES.NEW_TASK_DETAILS); + Navigation.goBack(ROUTES.NEW_TASK_DETAILS.getRoute(backTo)); }} /> {hasDestinationError && ( @@ -180,14 +180,14 @@ function NewTaskPage({task, reports, personalDetails}: NewTaskPageProps) { Navigation.navigate(ROUTES.NEW_TASK_TITLE)} + onPress={() => Navigation.navigate(ROUTES.NEW_TASK_TITLE.getRoute(backTo))} shouldShowRightIcon rightLabel={translate('common.required')} /> Navigation.navigate(ROUTES.NEW_TASK_DESCRIPTION)} + onPress={() => Navigation.navigate(ROUTES.NEW_TASK_DESCRIPTION.getRoute(backTo))} shouldShowRightIcon shouldParseTitle numberOfLinesTitle={2} @@ -198,7 +198,7 @@ function NewTaskPage({task, reports, personalDetails}: NewTaskPageProps) { title={assignee?.displayName ?? ''} description={assignee?.displayName ? LocalePhoneNumber.formatPhoneNumber(assignee?.subtitle) : translate('task.assignee')} icon={assignee?.icons} - onPress={() => Navigation.navigate(ROUTES.NEW_TASK_ASSIGNEE)} + onPress={() => Navigation.navigate(ROUTES.NEW_TASK_ASSIGNEE.getRoute(backTo))} shouldShowRightIcon titleWithTooltips={assigneeTooltipDetails} /> diff --git a/src/pages/tasks/NewTaskTitlePage.tsx b/src/pages/tasks/NewTaskTitlePage.tsx index cdc9fc27596a..3b45418db87d 100644 --- a/src/pages/tasks/NewTaskTitlePage.tsx +++ b/src/pages/tasks/NewTaskTitlePage.tsx @@ -29,12 +29,13 @@ type NewTaskTitlePageOnyxProps = { }; type NewTaskTitlePageProps = NewTaskTitlePageOnyxProps & StackScreenProps; -function NewTaskTitlePage({task}: NewTaskTitlePageProps) { +function NewTaskTitlePage({task, route}: NewTaskTitlePageProps) { const styles = useThemeStyles(); const {inputCallbackRef} = useAutoFocusInput(); const {translate} = useLocalize(); + const goBack = () => Navigation.goBack(ROUTES.NEW_TASK.getRoute(route.params.backTo)); const validate = (values: FormOnyxValues): FormInputErrors => { const errors = {}; @@ -52,7 +53,7 @@ function NewTaskTitlePage({task}: NewTaskTitlePageProps) { // the response const onSubmit = (values: FormOnyxValues) => { TaskActions.setTitleValue(values.taskTitle); - Navigation.goBack(ROUTES.NEW_TASK); + goBack(); }; return ( @@ -63,9 +64,8 @@ function NewTaskTitlePage({task}: NewTaskTitlePageProps) { > TaskActions.dismissModalAndClearOutTaskInfo()} shouldShowBackButton - onBackButtonPress={() => Navigation.goBack(ROUTES.NEW_TASK)} + onBackButtonPress={goBack} /> >(); const {translate} = useLocalize(); const session = useSession(); + const backTo = 'backTo' in route.params ? (route.params.backTo as string) : ''; const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const {userToInvite, recentReports, personalDetails, currentUserOption, searchValue, debouncedSearchValue, setSearchValue, headerMessage, areOptionsInitialized} = useOptions(); @@ -210,14 +211,14 @@ function TaskAssigneeSelectorModal({reports, task}: TaskAssigneeSelectorModalPro OptionsListUtils.isCurrentUser({...option, accountID: option?.accountID ?? -1, login: option?.login ?? undefined}), ); InteractionManager.runAfterInteractions(() => { - Navigation.goBack(ROUTES.NEW_TASK); + Navigation.goBack(ROUTES.NEW_TASK.getRoute(backTo)); }); } }, - [session?.accountID, task?.shareDestination, report], + [session?.accountID, task?.shareDestination, report, backTo], ); - const handleBackButtonPress = useCallback(() => (route.params?.reportID ? Navigation.dismissModal() : Navigation.goBack(ROUTES.NEW_TASK)), [route.params]); + const handleBackButtonPress = useCallback(() => (route.params?.reportID ? Navigation.dismissModal() : Navigation.goBack(ROUTES.NEW_TASK.getRoute(backTo))), [route.params, backTo]); const isOpen = ReportUtils.isOpenTaskReport(report); const canModifyTask = TaskActions.canModifyTask(report, currentUserPersonalDetails.accountID); diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.tsx b/src/pages/tasks/TaskShareDestinationSelectorModal.tsx index 1754c512bd6b..8cd38a54f7f9 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.tsx +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.tsx @@ -31,7 +31,7 @@ const selectReportHandler = (option: unknown) => { } Task.setShareDestinationValue(optionItem?.reportID); - Navigation.goBack(ROUTES.NEW_TASK); + Navigation.goBack(ROUTES.NEW_TASK.getRoute()); }; const reportFilter = (reportOptions: Array>) => @@ -130,7 +130,7 @@ function TaskShareDestinationSelectorModal() { <> Navigation.goBack(ROUTES.NEW_TASK)} + onBackButtonPress={() => Navigation.goBack(ROUTES.NEW_TASK.getRoute())} /> Date: Mon, 26 Aug 2024 18:31:19 +0800 Subject: [PATCH 02/18] add more backTo to currency page --- src/ROUTES.ts | 6 +++--- .../MoneyRequestConfirmationListFooter.tsx | 2 +- src/components/ReportActionItem/MoneyRequestView.tsx | 1 + src/libs/Navigation/types.ts | 2 ++ src/pages/iou/request/step/IOURequestStepAmount.tsx | 6 ++---- .../iou/request/step/IOURequestStepCurrency.tsx | 12 ++++-------- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 2364e7a384f7..36ce107d8cea 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -377,9 +377,9 @@ const ROUTES = { `${action as string}/${iouType as string}/confirmation/${transactionID}/${reportID}${participantsAutoAssigned ? '?participantsAutoAssigned=true' : ''}` as const, }, MONEY_REQUEST_STEP_AMOUNT: { - route: ':action/:iouType/amount/:transactionID/:reportID', - getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`${action as string}/${iouType as string}/amount/${transactionID}/${reportID}`, backTo), + route: ':action/:iouType/amount/:transactionID/:reportID/:pageIndex?', + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, pageIndex: string, backTo = '') => + getUrlWithBackToParam(`${action as string}/${iouType as string}/amount/${transactionID}/${reportID}/${pageIndex}`, backTo), }, MONEY_REQUEST_STEP_TAX_RATE: { route: ':action/:iouType/taxRate/:transactionID/:reportID?', diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx index 623348a4c7a4..b3c30e7fc4ee 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -282,7 +282,7 @@ function MoneyRequestConfirmationListFooter({ return; } - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(action, iouType, transactionID, reportID, 'confirm', Navigation.getActiveRouteWithoutParams())); }} style={[styles.moneyRequestMenuItem, styles.mt2]} titleStyle={styles.moneyRequestConfirmationAmount} diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index ebc78ffe84bc..b956a012eb2a 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -568,6 +568,7 @@ function MoneyRequestView({ iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1', + '', Navigation.getReportRHPActiveRoute(), ), ) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 8ed751ac9245..b071650fe677 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -897,6 +897,7 @@ type MoneyRequestNavigatorParamList = { backTo: never; action: never; currency: never; + pageIndex?: string; }; [SCREENS.MONEY_REQUEST.START]: { iouType: IOUType; @@ -910,6 +911,7 @@ type MoneyRequestNavigatorParamList = { transactionID: string; backTo: Routes; action: IOUAction; + pageIndex?: string; currency?: string; }; [SCREENS.MONEY_REQUEST.STEP_DISTANCE_RATE]: { diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 069f86ce0899..829c42aac132 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -62,7 +62,7 @@ type IOURequestStepAmountProps = IOURequestStepAmountOnyxProps & function IOURequestStepAmount({ report, route: { - params: {iouType, reportID, transactionID, backTo, action, currency: selectedCurrency = ''}, + params: {iouType, reportID, transactionID, backTo, pageIndex, action, currency: selectedCurrency = ''}, }, transaction, policy, @@ -133,9 +133,7 @@ function IOURequestStepAmount({ }; const navigateToCurrencySelectionPage = () => { - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CURRENCY.getRoute(action, iouType, transactionID, reportID, backTo ? 'confirm' : '', currency, Navigation.getActiveRouteWithoutParams()), - ); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CURRENCY.getRoute(action, iouType, transactionID, reportID, pageIndex, currency, Navigation.getActiveRoute())); }; const navigateToParticipantPage = () => { diff --git a/src/pages/iou/request/step/IOURequestStepCurrency.tsx b/src/pages/iou/request/step/IOURequestStepCurrency.tsx index 74600a5f3650..fd999fecac48 100644 --- a/src/pages/iou/request/step/IOURequestStepCurrency.tsx +++ b/src/pages/iou/request/step/IOURequestStepCurrency.tsx @@ -8,10 +8,10 @@ import useLocalize from '@hooks/useLocalize'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as ReportUtils from '@libs/ReportUtils'; +import {appendParam} from '@libs/Url'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES, {getUrlWithBackToParam} from '@src/ROUTES'; import type {Route} from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type {Transaction} from '@src/types/onyx'; @@ -28,7 +28,7 @@ type IOURequestStepCurrencyProps = IOURequestStepCurrencyOnyxProps & WithFullTra function IOURequestStepCurrency({ route: { - params: {backTo, iouType, pageIndex, reportID, transactionID, action, currency: selectedCurrency = ''}, + params: {backTo, pageIndex, transactionID, action, currency: selectedCurrency = ''}, }, draftTransaction, }: IOURequestStepCurrencyProps) { @@ -42,14 +42,10 @@ function IOURequestStepCurrency({ // are only able to handle one backTo param at a time and the user needs to go back to the amount page before going back // to the confirmation page if (pageIndex === 'confirm') { - const routeToAmountPageWithConfirmationAsBackTo = getUrlWithBackToParam( - backTo as string, - `/${ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)}`, - ); if (selectedCurrencyValue) { - Navigation.navigate(`${routeToAmountPageWithConfirmationAsBackTo}¤cy=${selectedCurrencyValue}` as Route); + Navigation.navigate(appendParam(backTo as string, 'currency', selectedCurrencyValue)); } else { - Navigation.goBack(routeToAmountPageWithConfirmationAsBackTo as Route); + Navigation.goBack(backTo as Route); } return; } From 61177b567cc6de030c43b58f7bed1eceda3e5a62 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 26 Aug 2024 19:00:10 +0800 Subject: [PATCH 03/18] lint --- src/pages/iou/request/step/IOURequestStepCurrency.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepCurrency.tsx b/src/pages/iou/request/step/IOURequestStepCurrency.tsx index fd999fecac48..7bef6e8cad48 100644 --- a/src/pages/iou/request/step/IOURequestStepCurrency.tsx +++ b/src/pages/iou/request/step/IOURequestStepCurrency.tsx @@ -45,7 +45,7 @@ function IOURequestStepCurrency({ if (selectedCurrencyValue) { Navigation.navigate(appendParam(backTo as string, 'currency', selectedCurrencyValue)); } else { - Navigation.goBack(backTo as Route); + Navigation.goBack(backTo); } return; } From caea4ae939a1998dff3cdee7973e2db8dd3df423 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 26 Aug 2024 19:11:40 +0800 Subject: [PATCH 04/18] remove unused import --- src/pages/iou/request/step/IOURequestStepCurrency.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepCurrency.tsx b/src/pages/iou/request/step/IOURequestStepCurrency.tsx index 7bef6e8cad48..8f8cdc731fb1 100644 --- a/src/pages/iou/request/step/IOURequestStepCurrency.tsx +++ b/src/pages/iou/request/step/IOURequestStepCurrency.tsx @@ -12,7 +12,6 @@ import {appendParam} from '@libs/Url'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Route} from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type {Transaction} from '@src/types/onyx'; import StepScreenWrapper from './StepScreenWrapper'; From 5530ac78625080d68756f1267fc95cb1e330ceb2 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 27 Aug 2024 12:07:43 +0800 Subject: [PATCH 05/18] use const --- src/CONST.ts | 3 +++ src/components/MoneyRequestConfirmationListFooter.tsx | 2 +- src/pages/iou/request/step/IOURequestStepCurrency.tsx | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 175aa8cd3c16..23bd27d01858 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1976,6 +1976,9 @@ const CONST = { ACCESS_VARIANTS: { CREATE: 'create', }, + PAGE_INDEX: { + CONFIRM: 'confirm', + }, }, GROWL: { diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx index 2dce23c84e8d..b5975090bc19 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -285,7 +285,7 @@ function MoneyRequestConfirmationListFooter({ return; } - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(action, iouType, transactionID, reportID, 'confirm', Navigation.getActiveRouteWithoutParams())); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(action, iouType, transactionID, reportID, CONST.IOU.PAGE_INDEX.CONFIRM, Navigation.getActiveRouteWithoutParams())); }} style={[styles.moneyRequestMenuItem, styles.mt2]} titleStyle={styles.moneyRequestConfirmationAmount} diff --git a/src/pages/iou/request/step/IOURequestStepCurrency.tsx b/src/pages/iou/request/step/IOURequestStepCurrency.tsx index 8f8cdc731fb1..548b4d075d78 100644 --- a/src/pages/iou/request/step/IOURequestStepCurrency.tsx +++ b/src/pages/iou/request/step/IOURequestStepCurrency.tsx @@ -40,7 +40,7 @@ function IOURequestStepCurrency({ // then the user needs taken back to the confirmation page instead of the initial amount page. This is because the route params // are only able to handle one backTo param at a time and the user needs to go back to the amount page before going back // to the confirmation page - if (pageIndex === 'confirm') { + if (pageIndex === CONST.IOU.PAGE_INDEX.CONFIRM) { if (selectedCurrencyValue) { Navigation.navigate(appendParam(backTo as string, 'currency', selectedCurrencyValue)); } else { @@ -53,7 +53,7 @@ function IOURequestStepCurrency({ const confirmCurrencySelection = (option: CurrencyListItem) => { Keyboard.dismiss(); - if (pageIndex !== 'confirm') { + if (pageIndex !== CONST.IOU.PAGE_INDEX.CONFIRM) { IOU.setMoneyRequestCurrency(transactionID, option.currencyCode, action === CONST.IOU.ACTION.EDIT); } From 74e4de7e4be4b66cef1ebe946d08fc422d1cc450 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 27 Aug 2024 12:18:27 +0800 Subject: [PATCH 06/18] prettier --- src/components/MoneyRequestConfirmationListFooter.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx index b5975090bc19..e7d2c597966d 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -285,7 +285,9 @@ function MoneyRequestConfirmationListFooter({ return; } - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(action, iouType, transactionID, reportID, CONST.IOU.PAGE_INDEX.CONFIRM, Navigation.getActiveRouteWithoutParams())); + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(action, iouType, transactionID, reportID, CONST.IOU.PAGE_INDEX.CONFIRM, Navigation.getActiveRouteWithoutParams()), + ); }} style={[styles.moneyRequestMenuItem, styles.mt2]} titleStyle={styles.moneyRequestConfirmationAmount} From e0ee34fffdc5210f418be253bfb08ba1f7de6b3a Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 29 Aug 2024 15:57:37 +0800 Subject: [PATCH 07/18] null safety --- src/pages/tasks/NewTaskDescriptionPage.tsx | 2 +- src/pages/tasks/NewTaskDetailsPage.tsx | 2 +- src/pages/tasks/NewTaskPage.tsx | 2 +- src/pages/tasks/NewTaskTitlePage.tsx | 2 +- src/pages/tasks/TaskAssigneeSelectorModal.tsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/tasks/NewTaskDescriptionPage.tsx b/src/pages/tasks/NewTaskDescriptionPage.tsx index 6689524cd11e..0132442b5978 100644 --- a/src/pages/tasks/NewTaskDescriptionPage.tsx +++ b/src/pages/tasks/NewTaskDescriptionPage.tsx @@ -39,7 +39,7 @@ function NewTaskDescriptionPage({task, route}: NewTaskDescriptionPageProps) { const {translate} = useLocalize(); const {inputCallbackRef, inputRef} = useAutoFocusInput(); - const goBack = () => Navigation.goBack(ROUTES.NEW_TASK.getRoute(route.params.backTo)); + const goBack = () => Navigation.goBack(ROUTES.NEW_TASK.getRoute(route.params?.backTo)); const onSubmit = (values: FormOnyxValues) => { TaskActions.setDescriptionValue(values.taskDescription); goBack(); diff --git a/src/pages/tasks/NewTaskDetailsPage.tsx b/src/pages/tasks/NewTaskDetailsPage.tsx index 09a21ad54c8f..f0ff4d0fb409 100644 --- a/src/pages/tasks/NewTaskDetailsPage.tsx +++ b/src/pages/tasks/NewTaskDetailsPage.tsx @@ -42,7 +42,7 @@ function NewTaskDetailsPage({task, route}: NewTaskDetailsPageProps) { const {inputCallbackRef} = useAutoFocusInput(); - const backTo = route.params.backTo; + const backTo = route.params?.backTo; const skipConfirmation = task?.skipConfirmation && task?.assigneeAccountID && task?.parentReportID; const buttonText = skipConfirmation ? translate('newTaskPage.assignTask') : translate('common.next'); diff --git a/src/pages/tasks/NewTaskPage.tsx b/src/pages/tasks/NewTaskPage.tsx index 89efe20c2477..faf45df8b51d 100644 --- a/src/pages/tasks/NewTaskPage.tsx +++ b/src/pages/tasks/NewTaskPage.tsx @@ -62,7 +62,7 @@ function NewTaskPage({task, reports, personalDetails, route}: NewTaskPageProps) const {paddingBottom} = useStyledSafeAreaInsets(); - const backTo = route.params.backTo; + const backTo = route.params?.backTo; const confirmButtonRef = useRef(null); const focusTimeoutRef = useRef(null); useFocusEffect( diff --git a/src/pages/tasks/NewTaskTitlePage.tsx b/src/pages/tasks/NewTaskTitlePage.tsx index 3b45418db87d..5afd919cac57 100644 --- a/src/pages/tasks/NewTaskTitlePage.tsx +++ b/src/pages/tasks/NewTaskTitlePage.tsx @@ -35,7 +35,7 @@ function NewTaskTitlePage({task, route}: NewTaskTitlePageProps) { const {translate} = useLocalize(); - const goBack = () => Navigation.goBack(ROUTES.NEW_TASK.getRoute(route.params.backTo)); + const goBack = () => Navigation.goBack(ROUTES.NEW_TASK.getRoute(route.params?.backTo)); const validate = (values: FormOnyxValues): FormInputErrors => { const errors = {}; diff --git a/src/pages/tasks/TaskAssigneeSelectorModal.tsx b/src/pages/tasks/TaskAssigneeSelectorModal.tsx index 677c248fe77a..00ccabe7e39f 100644 --- a/src/pages/tasks/TaskAssigneeSelectorModal.tsx +++ b/src/pages/tasks/TaskAssigneeSelectorModal.tsx @@ -116,7 +116,7 @@ function TaskAssigneeSelectorModal({reports, task}: TaskAssigneeSelectorModalPro const route = useRoute>(); const {translate} = useLocalize(); const session = useSession(); - const backTo = 'backTo' in route.params ? (route.params.backTo as string) : ''; + const backTo = route.params && 'backTo' in route.params ? (route.params.backTo as string) : ''; const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const {userToInvite, recentReports, personalDetails, currentUserOption, searchValue, debouncedSearchValue, setSearchValue, headerMessage, areOptionsInitialized} = useOptions(); From 4317aaaa5fd1dc464d21f6fee912d77162303cb2 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 31 Aug 2024 22:08:23 +0800 Subject: [PATCH 08/18] add and update backTo --- src/ROUTES.ts | 20 +++---- src/components/MoneyRequestHeader.tsx | 4 +- .../MoneyRequestPreviewContent.tsx | 17 +++--- src/hooks/useReviewDuplicatesNavigation.tsx | 60 +++++++++++++++---- src/libs/Navigation/types.ts | 9 +++ src/pages/ReportDetailsPage.tsx | 2 +- .../TransactionDuplicate/Confirmation.tsx | 9 ++- src/pages/TransactionDuplicate/Review.tsx | 5 +- .../TransactionDuplicate/ReviewBillable.tsx | 12 +++- .../TransactionDuplicate/ReviewCategory.tsx | 12 +++- .../ReviewDescription.tsx | 12 +++- .../TransactionDuplicate/ReviewMerchant.tsx | 12 +++- .../ReviewReimbursable.tsx | 12 +++- src/pages/TransactionDuplicate/ReviewTag.tsx | 12 +++- .../TransactionDuplicate/ReviewTaxCode.tsx | 12 +++- .../home/report/ReportActionItemSingle.tsx | 2 +- .../home/report/ReportDetailsExportPage.tsx | 8 ++- 17 files changed, 168 insertions(+), 52 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index f72744607f0f..0568272691c5 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -299,7 +299,7 @@ const ROUTES = { }, REPORT_WITH_ID_DETAILS_EXPORT: { route: 'r/:reportID/details/export/:connectionName', - getRoute: (reportID: string, connectionName: ConnectionName) => `r/${reportID}/details/export/${connectionName}` as const, + getRoute: (reportID: string, connectionName: ConnectionName, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/details/export/${connectionName}` as const, backTo), }, REPORT_SETTINGS: { route: 'r/:reportID/settings', @@ -1045,39 +1045,39 @@ const ROUTES = { }, TRANSACTION_DUPLICATE_REVIEW_PAGE: { route: 'r/:threadReportID/duplicates/review', - getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review` as const, + getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review` as const, backTo), }, TRANSACTION_DUPLICATE_REVIEW_MERCHANT_PAGE: { route: 'r/:threadReportID/duplicates/review/merchant', - getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/merchant` as const, + getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/merchant` as const, backTo), }, TRANSACTION_DUPLICATE_REVIEW_CATEGORY_PAGE: { route: 'r/:threadReportID/duplicates/review/category', - getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/category` as const, + getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/category` as const, backTo), }, TRANSACTION_DUPLICATE_REVIEW_TAG_PAGE: { route: 'r/:threadReportID/duplicates/review/tag', - getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/tag` as const, + getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/tag` as const, backTo), }, TRANSACTION_DUPLICATE_REVIEW_TAX_CODE_PAGE: { route: 'r/:threadReportID/duplicates/review/tax-code', - getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/tax-code` as const, + getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/tax-code` as const, backTo), }, TRANSACTION_DUPLICATE_REVIEW_DESCRIPTION_PAGE: { route: 'r/:threadReportID/duplicates/review/description', - getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/description` as const, + getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/description` as const, backTo), }, TRANSACTION_DUPLICATE_REVIEW_REIMBURSABLE_PAGE: { route: 'r/:threadReportID/duplicates/review/reimbursable', - getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/reimbursable` as const, + getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/reimbursable` as const, backTo), }, TRANSACTION_DUPLICATE_REVIEW_BILLABLE_PAGE: { route: 'r/:threadReportID/duplicates/review/billable', - getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/billable` as const, + getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/billable` as const, backTo), }, TRANSACTION_DUPLICATE_CONFIRMATION_PAGE: { route: 'r/:threadReportID/duplicates/confirm', - getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/confirm` as const, + getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/confirm` as const, backTo), }, POLICY_ACCOUNTING_XERO_IMPORT: { route: 'settings/workspaces/:policyID/accounting/xero/import', diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index 3d06deea9627..4a789d3e5df9 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -153,7 +153,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow text={translate('iou.reviewDuplicates')} style={[styles.p0, styles.ml2]} onPress={() => { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(report.reportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(report.reportID, Navigation.getReportRHPActiveRoute())); }} /> )} @@ -177,7 +177,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow text={translate('iou.reviewDuplicates')} style={[styles.w100, styles.pr0]} onPress={() => { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(report.reportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(report.reportID, Navigation.getReportRHPActiveRoute())); }} /> diff --git a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx index 6ab1c0937278..eda2bfa85de0 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx @@ -283,24 +283,25 @@ function MoneyRequestPreviewContent({ ); const navigateToReviewFields = () => { + const backTo = route.params.backTo; const comparisonResult = TransactionUtils.compareDuplicateTransactionFields(reviewingTransactionID); Transaction.setReviewDuplicatesKey({...comparisonResult.keep, duplicates, transactionID: transaction?.transactionID ?? ''}); if ('merchant' in comparisonResult.change) { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_MERCHANT_PAGE.getRoute(route.params?.threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_MERCHANT_PAGE.getRoute(route.params?.threadReportID, backTo)); } else if ('category' in comparisonResult.change) { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_CATEGORY_PAGE.getRoute(route.params?.threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_CATEGORY_PAGE.getRoute(route.params?.threadReportID, backTo)); } else if ('tag' in comparisonResult.change) { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_TAG_PAGE.getRoute(route.params?.threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_TAG_PAGE.getRoute(route.params?.threadReportID, backTo)); } else if ('description' in comparisonResult.change) { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_DESCRIPTION_PAGE.getRoute(route.params?.threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_DESCRIPTION_PAGE.getRoute(route.params?.threadReportID, backTo)); } else if ('taxCode' in comparisonResult.change) { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_TAX_CODE_PAGE.getRoute(route.params?.threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_TAX_CODE_PAGE.getRoute(route.params?.threadReportID, backTo)); } else if ('billable' in comparisonResult.change) { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_BILLABLE_PAGE.getRoute(route.params?.threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_BILLABLE_PAGE.getRoute(route.params?.threadReportID, backTo)); } else if ('reimbursable' in comparisonResult.change) { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_REIMBURSABLE_PAGE.getRoute(route.params?.threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_REIMBURSABLE_PAGE.getRoute(route.params?.threadReportID, backTo)); } else { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_CONFIRMATION_PAGE.getRoute(route.params?.threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_CONFIRMATION_PAGE.getRoute(route.params?.threadReportID, backTo)); } }; diff --git a/src/hooks/useReviewDuplicatesNavigation.tsx b/src/hooks/useReviewDuplicatesNavigation.tsx index e14731024c17..de905647e440 100644 --- a/src/hooks/useReviewDuplicatesNavigation.tsx +++ b/src/hooks/useReviewDuplicatesNavigation.tsx @@ -3,50 +3,86 @@ import Navigation from '@libs/Navigation/Navigation'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; -type StepName = 'description' | 'merchant' | 'category' | 'billable' | 'tag' | 'taxCode' | 'reimbursable'; +type StepName = 'description' | 'merchant' | 'category' | 'billable' | 'tag' | 'taxCode' | 'reimbursable' | 'confirmation'; -function useReviewDuplicatesNavigation(stepNames: string[], currentScreenName: StepName, threadReportID: string) { - const [nextScreen, setNextScreen] = useState(currentScreenName); +function useReviewDuplicatesNavigation(stepNames: string[], currentScreenName: StepName, threadReportID: string, backTo?: string) { + const [nextScreen, setNextScreen] = useState(); + const [prevScreen, setPrevScreen] = useState(); const [currentScreenIndex, setCurrentScreenIndex] = useState(0); const intersection = useMemo(() => CONST.REVIEW_DUPLICATES_ORDER.filter((element) => stepNames.includes(element)), [stepNames]); useEffect(() => { + if (currentScreenName === 'confirmation') { + setPrevScreen(intersection[intersection.length - 1] ?? ''); + return; + } const currentIndex = intersection.indexOf(currentScreenName); const nextScreenIndex = currentIndex + 1; + const prevScreenIndex = currentIndex - 1; setCurrentScreenIndex(currentIndex); setNextScreen(intersection[nextScreenIndex] ?? ''); + setPrevScreen(intersection[prevScreenIndex] ?? ''); }, [currentScreenName, intersection]); + const goBack = () => { + switch (prevScreen) { + case 'merchant': + Navigation.goBack(ROUTES.TRANSACTION_DUPLICATE_REVIEW_MERCHANT_PAGE.getRoute(threadReportID, backTo)); + break; + case 'category': + Navigation.goBack(ROUTES.TRANSACTION_DUPLICATE_REVIEW_CATEGORY_PAGE.getRoute(threadReportID, backTo)); + break; + case 'tag': + Navigation.goBack(ROUTES.TRANSACTION_DUPLICATE_REVIEW_TAG_PAGE.getRoute(threadReportID, backTo)); + break; + case 'description': + Navigation.goBack(ROUTES.TRANSACTION_DUPLICATE_REVIEW_DESCRIPTION_PAGE.getRoute(threadReportID, backTo)); + break; + case 'taxCode': + Navigation.goBack(ROUTES.TRANSACTION_DUPLICATE_REVIEW_TAX_CODE_PAGE.getRoute(threadReportID, backTo)); + break; + case 'reimbursable': + Navigation.goBack(ROUTES.TRANSACTION_DUPLICATE_REVIEW_REIMBURSABLE_PAGE.getRoute(threadReportID, backTo)); + break; + case 'billable': + Navigation.goBack(ROUTES.TRANSACTION_DUPLICATE_REVIEW_BILLABLE_PAGE.getRoute(threadReportID, backTo)); + break; + default: + Navigation.goBack(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(threadReportID, backTo)); + break; + } + }; + const navigateToNextScreen = () => { switch (nextScreen) { case 'merchant': - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_MERCHANT_PAGE.getRoute(threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_MERCHANT_PAGE.getRoute(threadReportID, backTo)); break; case 'category': - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_CATEGORY_PAGE.getRoute(threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_CATEGORY_PAGE.getRoute(threadReportID, backTo)); break; case 'tag': - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_TAG_PAGE.getRoute(threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_TAG_PAGE.getRoute(threadReportID, backTo)); break; case 'description': - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_DESCRIPTION_PAGE.getRoute(threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_DESCRIPTION_PAGE.getRoute(threadReportID, backTo)); break; case 'taxCode': - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_TAX_CODE_PAGE.getRoute(threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_TAX_CODE_PAGE.getRoute(threadReportID, backTo)); break; case 'reimbursable': - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_REIMBURSABLE_PAGE.getRoute(threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_REIMBURSABLE_PAGE.getRoute(threadReportID, backTo)); break; case 'billable': - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_BILLABLE_PAGE.getRoute(threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_BILLABLE_PAGE.getRoute(threadReportID, backTo)); break; default: - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_CONFIRMATION_PAGE.getRoute(threadReportID)); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_CONFIRMATION_PAGE.getRoute(threadReportID, backTo)); break; } }; - return {navigateToNextScreen, currentScreenIndex}; + return {navigateToNextScreen, goBack, currentScreenIndex}; } export default useReviewDuplicatesNavigation; diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 4b5d9299e40a..4736364b86e2 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -761,6 +761,7 @@ type ReportDetailsNavigatorParamList = { reportID: string; policyID: string; connectionName: ConnectionName; + backTo?: Routes; }; }; @@ -1086,27 +1087,35 @@ type PrivateNotesNavigatorParamList = { type TransactionDuplicateNavigatorParamList = { [SCREENS.TRANSACTION_DUPLICATE.REVIEW]: { threadReportID: string; + backTo?: Routes; }; [SCREENS.TRANSACTION_DUPLICATE.MERCHANT]: { threadReportID: string; + backTo?: Routes; }; [SCREENS.TRANSACTION_DUPLICATE.CATEGORY]: { threadReportID: string; + backTo?: Routes; }; [SCREENS.TRANSACTION_DUPLICATE.TAG]: { threadReportID: string; + backTo?: Routes; }; [SCREENS.TRANSACTION_DUPLICATE.DESCRIPTION]: { threadReportID: string; + backTo?: Routes; }; [SCREENS.TRANSACTION_DUPLICATE.TAX_CODE]: { threadReportID: string; + backTo?: Routes; }; [SCREENS.TRANSACTION_DUPLICATE.BILLABLE]: { threadReportID: string; + backTo?: Routes; }; [SCREENS.TRANSACTION_DUPLICATE.REIMBURSABLE]: { threadReportID: string; + backTo?: Routes; }; }; diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 82a6a28c30f1..29ead7a7fef3 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -409,7 +409,7 @@ function ReportDetailsPage({policies, report, session, personalDetails, route}: icon: Expensicons.Upload, isAnonymousAction: false, action: () => { - Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS_EXPORT.getRoute(report?.reportID ?? '', connectedIntegration)); + Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS_EXPORT.getRoute(report?.reportID ?? '', connectedIntegration, backTo)); }, }); } diff --git a/src/pages/TransactionDuplicate/Confirmation.tsx b/src/pages/TransactionDuplicate/Confirmation.tsx index 96b32006675e..fa96190530fe 100644 --- a/src/pages/TransactionDuplicate/Confirmation.tsx +++ b/src/pages/TransactionDuplicate/Confirmation.tsx @@ -15,6 +15,7 @@ import ScrollView from '@components/ScrollView'; import {ShowContextMenuContext} from '@components/ShowContextMenuContext'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; +import useReviewDuplicatesNavigation from '@hooks/useReviewDuplicatesNavigation'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; import type {TransactionDuplicateNavigatorParamList} from '@libs/Navigation/types'; @@ -36,6 +37,9 @@ function Confirmation() { const route = useRoute>(); const [reviewDuplicates, reviewDuplicatesResult] = useOnyx(ONYXKEYS.REVIEW_DUPLICATES); const transaction = useMemo(() => TransactionUtils.buildNewTransactionAfterReviewingDuplicates(reviewDuplicates), [reviewDuplicates]); + const transactionID = TransactionUtils.getTransactionID(route.params.threadReportID ?? ''); + const compareResult = TransactionUtils.compareDuplicateTransactionFields(transactionID); + const {goBack} = useReviewDuplicatesNavigation(Object.keys(compareResult.change ?? {}), 'confirmation', route.params.threadReportID, route.params.backTo); const [report, reportResult] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`); const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transaction?.reportID}`); const reportAction = Object.values(reportActions ?? {}).find( @@ -82,7 +86,10 @@ function Confirmation() { {({safeAreaPaddingBottomStyle}) => ( - + - + Navigation.goBack(route.params.backTo)} + />