Skip to content

Commit c00f1c0

Browse files
authored
Merge pull request #56345 from FitseTLT/fix-navigation-back-of-private-notes-list-page
2 parents 3bc5f23 + e1a2645 commit c00f1c0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/libs/ReportUtils.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -4626,7 +4626,7 @@ function navigateToDetailsPage(report: OnyxEntry<Report>, backTo?: string) {
46264626
/**
46274627
* Go back to the details page of a given report
46284628
*/
4629-
function goBackToDetailsPage(report: OnyxEntry<Report>, backTo?: string) {
4629+
function goBackToDetailsPage(report: OnyxEntry<Report>, backTo?: string, shouldGoBackToDetailsPage = false) {
46304630
const isOneOnOneChatReport = isOneOnOneChat(report);
46314631
const participantAccountID = getParticipantsAccountIDsForDisplay(report);
46324632

@@ -4636,7 +4636,11 @@ function goBackToDetailsPage(report: OnyxEntry<Report>, backTo?: string) {
46364636
}
46374637

46384638
if (report?.reportID) {
4639-
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID, backTo));
4639+
if (shouldGoBackToDetailsPage) {
4640+
Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID, backTo));
4641+
} else {
4642+
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID, backTo));
4643+
}
46404644
} else {
46414645
Log.warn('Missing reportID during navigation back to the details page');
46424646
}

src/pages/PrivateNotes/PrivateNotesListPage.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
1313
import Navigation from '@libs/Navigation/Navigation';
1414
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
1515
import type {PrivateNotesNavigatorParamList} from '@libs/Navigation/types';
16+
import {goBackToDetailsPage} from '@libs/ReportUtils';
1617
import type {WithReportAndPrivateNotesOrNotFoundProps} from '@pages/home/report/withReportAndPrivateNotesOrNotFound';
1718
import withReportAndPrivateNotesOrNotFound from '@pages/home/report/withReportAndPrivateNotesOrNotFound';
1819
import CONST from '@src/CONST';
@@ -94,7 +95,7 @@ function PrivateNotesListPage({report, accountID: sessionAccountID}: PrivateNote
9495
<HeaderWithBackButton
9596
title={translate('privateNotes.title')}
9697
shouldShowBackButton
97-
onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID, backTo))}
98+
onBackButtonPress={() => goBackToDetailsPage(report, route.params.backTo, true)}
9899
onCloseButtonPress={() => Navigation.dismissModal()}
99100
/>
100101
<ScrollView

0 commit comments

Comments
 (0)