From a9aabc3eb01641acd18b170486e08f26bd69b6f7 Mon Sep 17 00:00:00 2001
From: Wojciech Lewicki <wojciech.lewicki@swmansion.com>
Date: Wed, 7 Jun 2023 15:02:46 +0200
Subject: [PATCH 1/3] fix: always use goBack instead of navigate for header
 back button

---
 src/pages/ReportDetailsPage.js                     | 5 +----
 src/pages/settings/Payments/TransferBalancePage.js | 4 ++--
 src/pages/workspace/WorkspaceInitialPage.js        | 2 +-
 src/pages/workspace/WorkspaceInviteMessagePage.js  | 2 +-
 src/pages/workspace/WorkspaceInvitePage.js         | 2 +-
 src/pages/workspace/WorkspaceMembersPage.js        | 2 +-
 src/pages/workspace/WorkspacePageWithSections.js   | 2 +-
 7 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js
index 1baf0b6151d9..98f7694533e4 100644
--- a/src/pages/ReportDetailsPage.js
+++ b/src/pages/ReportDetailsPage.js
@@ -137,10 +137,7 @@ const ReportDetailsPage = (props) => {
     return (
         <ScreenWrapper>
             <FullPageNotFoundView shouldShow={_.isEmpty(props.report)}>
-                <HeaderWithBackButton
-                    title={props.translate('common.details')}
-                    onBackButtonPress={() => Navigation.goBack()}
-                />
+                <HeaderWithBackButton title={props.translate('common.details')} />
                 <ScrollView style={[styles.flex1]}>
                     <View style={styles.reportDetailsTitleContainer}>
                         <View style={styles.mb3}>
diff --git a/src/pages/settings/Payments/TransferBalancePage.js b/src/pages/settings/Payments/TransferBalancePage.js
index dd73d0174863..9000c86ab091 100644
--- a/src/pages/settings/Payments/TransferBalancePage.js
+++ b/src/pages/settings/Payments/TransferBalancePage.js
@@ -178,12 +178,12 @@ class TransferBalancePage extends React.Component {
                     subtitleKey="transferAmountPage.notHereSubTitle"
                     shouldShowLink
                     linkKey="transferAmountPage.goToPayment"
-                    onLinkPress={() => Navigation.navigate(ROUTES.SETTINGS_PAYMENTS)}
+                    onLinkPress={() => Navigation.goBack(ROUTES.SETTINGS_PAYMENTS)}
                 >
                     <HeaderWithBackButton
                         title={this.props.translate('common.transferBalance')}
                         shouldShowBackButton
-                        onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_PAYMENTS)}
+                        onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PAYMENTS)}
                     />
                     <View style={[styles.flexGrow1, styles.flexShrink1, styles.flexBasisAuto, styles.justifyContentCenter]}>
                         <CurrentWalletBalance balanceStyles={[styles.transferBalanceBalance]} />
diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js
index 6c70f0f20b16..92d8e0fe0f3d 100644
--- a/src/pages/workspace/WorkspaceInitialPage.js
+++ b/src/pages/workspace/WorkspaceInitialPage.js
@@ -164,7 +164,7 @@ const WorkspaceInitialPage = (props) => {
             {({safeAreaPaddingBottomStyle}) => (
                 <FullPageNotFoundView
                     shouldShow={_.isEmpty(policy)}
-                    onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)}
+                    onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)}
                 >
                     <HeaderWithBackButton
                         title={props.translate('workspace.common.workspace')}
diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.js b/src/pages/workspace/WorkspaceInviteMessagePage.js
index bf0bad6710e6..eb53319ffd38 100644
--- a/src/pages/workspace/WorkspaceInviteMessagePage.js
+++ b/src/pages/workspace/WorkspaceInviteMessagePage.js
@@ -144,7 +144,7 @@ class WorkspaceInviteMessagePage extends React.Component {
             <ScreenWrapper includeSafeAreaPaddingBottom={false}>
                 <FullPageNotFoundView
                     shouldShow={_.isEmpty(this.props.policy)}
-                    onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)}
+                    onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)}
                 >
                     <HeaderWithBackButton
                         title={this.props.translate('workspace.inviteMessage.inviteMessageTitle')}
diff --git a/src/pages/workspace/WorkspaceInvitePage.js b/src/pages/workspace/WorkspaceInvitePage.js
index 60eb0a4c4dcc..19a5e9375206 100644
--- a/src/pages/workspace/WorkspaceInvitePage.js
+++ b/src/pages/workspace/WorkspaceInvitePage.js
@@ -256,7 +256,7 @@ class WorkspaceInvitePage extends React.Component {
             <ScreenWrapper shouldEnableMaxHeight>
                 <FullPageNotFoundView
                     shouldShow={_.isEmpty(this.props.policy)}
-                    onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)}
+                    onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)}
                 >
                     <FormSubmit
                         style={[styles.flex1]}
diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js
index 5206c34c1a49..dcf70386255d 100644
--- a/src/pages/workspace/WorkspaceMembersPage.js
+++ b/src/pages/workspace/WorkspaceMembersPage.js
@@ -413,7 +413,7 @@ class WorkspaceMembersPage extends React.Component {
                 {({safeAreaPaddingBottomStyle}) => (
                     <FullPageNotFoundView
                         shouldShow={_.isEmpty(this.props.policy)}
-                        onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)}
+                        onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)}
                     >
                         <HeaderWithBackButton
                             title={this.props.translate('workspace.common.members')}
diff --git a/src/pages/workspace/WorkspacePageWithSections.js b/src/pages/workspace/WorkspacePageWithSections.js
index 66f8317318d3..97f8fd6795e0 100644
--- a/src/pages/workspace/WorkspacePageWithSections.js
+++ b/src/pages/workspace/WorkspacePageWithSections.js
@@ -116,7 +116,7 @@ class WorkspacePageWithSections extends React.Component {
             >
                 <FullPageNotFoundView
                     shouldShow={_.isEmpty(this.props.policy)}
-                    onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)}
+                    onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)}
                 >
                     <HeaderWithBackButton
                         title={this.props.headerText}

From ba78dd09195d8a770921269d8224215649d27433 Mon Sep 17 00:00:00 2001
From: Wojciech Lewicki <wojciech.lewicki@swmansion.com>
Date: Wed, 7 Jun 2023 15:10:42 +0200
Subject: [PATCH 2/3] fix: correct route for going back

---
 src/pages/ShareCodePage.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/pages/ShareCodePage.js b/src/pages/ShareCodePage.js
index 6d92f1a94afb..30e6d272009f 100644
--- a/src/pages/ShareCodePage.js
+++ b/src/pages/ShareCodePage.js
@@ -18,6 +18,7 @@ import getPlatform from '../libs/getPlatform';
 import CONST from '../CONST';
 import ContextMenuItem from '../components/ContextMenuItem';
 import * as UserUtils from '../libs/UserUtils';
+import ROUTES from '../ROUTES';
 
 const propTypes = {
     /** The report currently being looked at */
@@ -49,7 +50,7 @@ class ShareCodePage extends React.Component {
             <ScreenWrapper>
                 <HeaderWithBackButton
                     title={this.props.translate('common.shareCode')}
-                    onBackButtonPress={() => Navigation.goBack()}
+                    onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)}
                 />
 
                 <ScrollView style={[styles.flex1, styles.mt3]}>

From d4cf445bac52b6bcc228f926184c714b1489fccb Mon Sep 17 00:00:00 2001
From: Wojciech Lewicki <wojciech.lewicki@swmansion.com>
Date: Wed, 7 Jun 2023 16:42:03 +0200
Subject: [PATCH 3/3] fix: sharecode in report

---
 src/pages/ShareCodePage.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pages/ShareCodePage.js b/src/pages/ShareCodePage.js
index 30e6d272009f..456fbe78d6db 100644
--- a/src/pages/ShareCodePage.js
+++ b/src/pages/ShareCodePage.js
@@ -50,7 +50,7 @@ class ShareCodePage extends React.Component {
             <ScreenWrapper>
                 <HeaderWithBackButton
                     title={this.props.translate('common.shareCode')}
-                    onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)}
+                    onBackButtonPress={() => Navigation.goBack(isReport ? ROUTES.getReportDetailsRoute(this.props.report.reportID) : ROUTES.SETTINGS)}
                 />
 
                 <ScrollView style={[styles.flex1, styles.mt3]}>
