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

Wildan/21518/fix #22787

Merged
merged 9 commits into from
Jul 13, 2023
29 changes: 25 additions & 4 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class ReportScreen extends React.Component {
this.state = {
skeletonViewContainerHeight: reportActionsListViewHeight,
isBannerVisible: true,
isReportRemoved: false,
};
this.firstRenderRef = React.createRef();
this.firstRenderRef.current = reportActionsListViewHeight === 0;
Expand Down Expand Up @@ -160,13 +161,33 @@ class ReportScreen extends React.Component {
if (ReportUtils.shouldHideComposer(this.props.report, this.props.errors)) {
EmojiPickerAction.hideEmojiPicker(true);
}
const onyxReportID = this.props.report.reportID;
const prevOnyxReportID = prevProps.report.reportID;
const routeReportID = getReportID(this.props.route);

// navigate to concierge when the room removed from another device (e.g. user leaving a room)
// the report will not really null when removed, it will have defaultProps properties and values
if (
prevOnyxReportID &&
prevOnyxReportID === routeReportID &&
!onyxReportID &&
// non-optimistic case
(_.isEqual(this.props.report, defaultProps.report) ||
// optimistic case
(prevProps.report.statusNum === CONST.REPORT.STATUS.OPEN && this.props.report.statusNum === CONST.REPORT.STATUS.CLOSED))
) {
Navigation.goBack();
Report.navigateToConciergeChat();
// isReportRemoved will prevent <FullPageNotFoundView> showing when navigating
this.setState({isReportRemoved: true});
return;
}

// If you already have a report open and are deeplinking to a new report on native,
// the ReportScreen never actually unmounts and the reportID in the route also doesn't change.
// Therefore, we need to compare if the existing reportID is the same as the one in the route
// before deciding that we shouldn't call OpenReport.
const onyxReportID = this.props.report.reportID;
const routeReportID = getReportID(this.props.route);
if (onyxReportID === prevProps.report.reportID && (!onyxReportID || onyxReportID === routeReportID)) {
if (onyxReportID === prevOnyxReportID && (!onyxReportID || onyxReportID === routeReportID)) {
return;
}

Expand Down Expand Up @@ -266,7 +287,7 @@ class ReportScreen extends React.Component {
shouldEnableKeyboardAvoidingView={this.props.isFocused}
>
<FullPageNotFoundView
shouldShow={(!this.props.report.reportID && !this.props.report.isLoadingReportActions && !isLoading) || shouldHideReport}
shouldShow={(!this.props.report.reportID && !this.props.report.isLoadingReportActions && !isLoading && !this.state.isReportRemoved) || shouldHideReport}
subtitleKey="notFound.noAccess"
shouldShowCloseButton={false}
shouldShowBackButton={this.props.isSmallScreenWidth}
Expand Down