Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigate back to the last accessed report when leaving a thread #42132

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import * as Environment from '@libs/Environment/Environment';
import * as ErrorUtils from '@libs/ErrorUtils';
import Log from '@libs/Log';
import * as LoginUtils from '@libs/LoginUtils';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
import Navigation from '@libs/Navigation/Navigation';
import type {NetworkStatus} from '@libs/NetworkConnection';
import LocalNotification from '@libs/Notification/LocalNotification';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
Expand Down Expand Up @@ -2530,13 +2530,7 @@ function navigateToMostRecentReport(currentReport: OnyxEntry<Report>) {
const isChatThread = ReportUtils.isChatThread(currentReport);
if (lastAccessedReportID) {
const lastAccessedReportRoute = ROUTES.REPORT_WITH_ID.getRoute(lastAccessedReportID ?? '');
// We are using index 1 here because on index 0, we'll always have the bottomTabNavigator.
const isFirstRoute = navigationRef?.current?.getState()?.index === 1;
// If it is not a chat thread we should call Navigation.goBack to pop the current route first before navigating to last accessed report.
if (!isChatThread && !isFirstRoute) {
Navigation.goBack();
}
Navigation.navigate(lastAccessedReportRoute, CONST.NAVIGATION.TYPE.FORCED_UP);
Navigation.goBack(lastAccessedReportRoute);
} else {
const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.CONCIERGE]);
const chat = ReportUtils.getChatByParticipants([...participantAccountIDs, currentUserAccountID]);
Expand Down
Loading