diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index 688b691fb62c..02bd202c1d2c 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -22,7 +22,7 @@ import MenuItem from '../components/MenuItem'; import Text from '../components/Text'; import CONST from '../CONST'; import reportPropTypes from './reportPropTypes'; -import withReportOrNavigateHome from './home/report/withReportOrNavigateHome'; +import withReportOrNotFound from './home/report/withReportOrNotFound'; import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView'; const propTypes = { @@ -181,7 +181,7 @@ ReportDetailsPage.propTypes = propTypes; export default compose( withLocalize, - withReportOrNavigateHome, + withReportOrNotFound, withOnyx({ personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS, diff --git a/src/pages/ReportParticipantsPage.js b/src/pages/ReportParticipantsPage.js index 07c4d62b448a..eb682d5026be 100755 --- a/src/pages/ReportParticipantsPage.js +++ b/src/pages/ReportParticipantsPage.js @@ -19,7 +19,7 @@ import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; import compose from '../libs/compose'; import * as ReportUtils from '../libs/ReportUtils'; import reportPropTypes from './reportPropTypes'; -import withReportOrNavigateHome from './home/report/withReportOrNavigateHome'; +import withReportOrNotFound from './home/report/withReportOrNotFound'; import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView'; const propTypes = { @@ -118,7 +118,7 @@ ReportParticipantsPage.displayName = 'ReportParticipantsPage'; export default compose( withLocalize, - withReportOrNavigateHome, + withReportOrNotFound, withOnyx({ personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS, diff --git a/src/pages/ReportSettingsPage.js b/src/pages/ReportSettingsPage.js index 86fa8b6cec16..fca21166d0f6 100644 --- a/src/pages/ReportSettingsPage.js +++ b/src/pages/ReportSettingsPage.js @@ -20,7 +20,7 @@ import Picker from '../components/Picker'; import * as ValidationUtils from '../libs/ValidationUtils'; import OfflineWithFeedback from '../components/OfflineWithFeedback'; import reportPropTypes from './reportPropTypes'; -import withReportOrNavigateHome from './home/report/withReportOrNavigateHome'; +import withReportOrNotFound from './home/report/withReportOrNotFound'; import Form from '../components/Form'; import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView'; @@ -220,7 +220,7 @@ ReportSettingsPage.propTypes = propTypes; export default compose( withLocalize, - withReportOrNavigateHome, + withReportOrNotFound, withOnyx({ policies: { key: ONYXKEYS.COLLECTION.POLICY, diff --git a/src/pages/home/report/withReportOrNavigateHome.js b/src/pages/home/report/withReportOrNotFound.js similarity index 68% rename from src/pages/home/report/withReportOrNavigateHome.js rename to src/pages/home/report/withReportOrNotFound.js index 5e74f65a0cb8..e1e3b0f64ef0 100644 --- a/src/pages/home/report/withReportOrNavigateHome.js +++ b/src/pages/home/report/withReportOrNotFound.js @@ -3,7 +3,7 @@ import React, {Component} from 'react'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import getComponentDisplayName from '../../../libs/getComponentDisplayName'; -import Navigation from '../../../libs/Navigation/Navigation'; +import NotFoundPage from '../../ErrorPage/NotFoundPage'; import ONYXKEYS from '../../../ONYXKEYS'; import reportPropTypes from '../../reportPropTypes'; @@ -22,15 +22,12 @@ export default function (WrappedComponent) { report: {}, }; - class WithReportOrNavigateHome extends Component { - componentDidMount() { - if (!_.isEmpty(this.props.report)) { - return; + class WithReportOrNotFound extends Component { + render() { + if (_.isEmpty(this.props.report) || !this.props.report.reportID) { + return ; } - Navigation.dismissModal(); - } - render() { const rest = _.omit(this.props, ['forwardedRef']); return ( @@ -43,17 +40,18 @@ export default function (WrappedComponent) { } } - WithReportOrNavigateHome.propTypes = propTypes; - WithReportOrNavigateHome.defaultProps = defaultProps; - WithReportOrNavigateHome.displayName = `withReportOrNavigateHome(${getComponentDisplayName(WrappedComponent)})`; - const withReportOrNavigateHome = React.forwardRef((props, ref) => ( + WithReportOrNotFound.propTypes = propTypes; + WithReportOrNotFound.defaultProps = defaultProps; + WithReportOrNotFound.displayName = `withReportOrNotFound(${getComponentDisplayName(WrappedComponent)})`; + // eslint-disable-next-line rulesdir/no-negated-variables + const withReportOrNotFound = React.forwardRef((props, ref) => ( // eslint-disable-next-line react/jsx-props-no-spreading - + )); return withOnyx({ report: { key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID}`, }, - })(withReportOrNavigateHome); + })(withReportOrNotFound); }