Skip to content

Commit

Permalink
Merge pull request #56345 from FitseTLT/fix-navigation-back-of-privat…
Browse files Browse the repository at this point in the history
…e-notes-list-page
  • Loading branch information
flodnv authored Feb 5, 2025
2 parents 3bc5f23 + e1a2645 commit c00f1c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4626,7 +4626,7 @@ function navigateToDetailsPage(report: OnyxEntry<Report>, backTo?: string) {
/**
* Go back to the details page of a given report
*/
function goBackToDetailsPage(report: OnyxEntry<Report>, backTo?: string) {
function goBackToDetailsPage(report: OnyxEntry<Report>, backTo?: string, shouldGoBackToDetailsPage = false) {
const isOneOnOneChatReport = isOneOnOneChat(report);
const participantAccountID = getParticipantsAccountIDsForDisplay(report);

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

if (report?.reportID) {
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID, backTo));
if (shouldGoBackToDetailsPage) {
Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID, backTo));
} else {
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID, backTo));
}
} else {
Log.warn('Missing reportID during navigation back to the details page');
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/PrivateNotes/PrivateNotesListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
import type {PrivateNotesNavigatorParamList} from '@libs/Navigation/types';
import {goBackToDetailsPage} from '@libs/ReportUtils';
import type {WithReportAndPrivateNotesOrNotFoundProps} from '@pages/home/report/withReportAndPrivateNotesOrNotFound';
import withReportAndPrivateNotesOrNotFound from '@pages/home/report/withReportAndPrivateNotesOrNotFound';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -94,7 +95,7 @@ function PrivateNotesListPage({report, accountID: sessionAccountID}: PrivateNote
<HeaderWithBackButton
title={translate('privateNotes.title')}
shouldShowBackButton
onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID, backTo))}
onBackButtonPress={() => goBackToDetailsPage(report, route.params.backTo, true)}
onCloseButtonPress={() => Navigation.dismissModal()}
/>
<ScrollView
Expand Down

0 comments on commit c00f1c0

Please sign in to comment.