Skip to content

Room - Infinite loading when user is removed from room while in RHP #59126

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

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
25 changes: 20 additions & 5 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import useViewportOffsetTop from '@hooks/useViewportOffsetTop';
import {hideEmojiPicker} from '@libs/actions/EmojiPickerAction';
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import clearReportNotifications from '@libs/Notification/clearReportNotifications';
import {getPersonalDetailsForAccountIDs} from '@libs/OptionsListUtils';
Expand Down Expand Up @@ -81,7 +81,7 @@ import {
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import HeaderView from './HeaderView';
Expand All @@ -103,6 +103,8 @@ const defaultReportMetadata = {
isOptimisticReport: false,
};

const reportDetailScreens = [...Object.values(SCREENS.REPORT_DETAILS), ...Object.values(SCREENS.REPORT_SETTINGS), ...Object.values(SCREENS.PRIVATE_NOTES)];

/**
* Check is the report is deleted.
* We currently use useMemo to memorize every properties of the report
Expand Down Expand Up @@ -551,15 +553,24 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
isClosedTopLevelPolicyRoom ||
(prevDeletedParentAction && !deletedParentAction)
) {
const currentRoute = navigationRef.getCurrentRoute();
const isReportDetailOpenInRHP =
isTopMostReportId &&
reportDetailScreens.find((r) => r === currentRoute?.name) &&
!!currentRoute?.params &&
'reportID' in currentRoute.params &&
reportIDFromRoute === currentRoute.params.reportID;
// Early return if the report we're passing isn't in a focused state. We only want to navigate to Concierge if the user leaves the room from another device or gets removed from the room while the report is in a focused state.
// Prevent auto navigation for report in RHP
if (!isFocused || isInNarrowPaneModal) {
if ((!isFocused && !isReportDetailOpenInRHP) || isInNarrowPaneModal) {
return;
}
Navigation.dismissModal();
if (Navigation.getTopmostReportId() === prevOnyxReportID) {
Navigation.setShouldPopAllStateOnUP(true);
Navigation.goBack(undefined, {shouldPopToTop: true});
Navigation.isNavigationReady().then(() => {
Navigation.goBack(undefined, {shouldPopToTop: true});
});
}
if (prevReport?.parentReportID) {
// Prevent navigation to the IOU/Expense Report if it is pending deletion.
Expand All @@ -570,7 +581,11 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
return;
}

navigateToConciergeChat();
Navigation.isNavigationReady().then(() => {
InteractionManager.runAfterInteractions(() => {
navigateToConciergeChat();
});
});
return;
}

Expand Down