diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 99ad067484fc..ec0cebb3833b 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -200,14 +200,6 @@ class ReportScreen extends React.Component { } render() { - if (ReportUtils.isDefaultRoom(this.props.report) && !ReportUtils.canSeeDefaultRoom(this.props.report, this.props.policies, this.props.betas)) { - return null; - } - - if (!Permissions.canUsePolicyRooms(this.props.betas) && ReportUtils.isUserCreatedPolicyRoom(this.props.report)) { - return null; - } - // We are either adding a workspace room, or we're creating a chat, it isn't possible for both of these to be pending, or to have errors for the same report at the same time, so // simply looking up the first truthy value for each case will get the relevant property if it's set. const reportID = getReportID(this.props.route); @@ -218,6 +210,11 @@ class ReportScreen extends React.Component { // There are no reportActions at all to display and we are still in the process of loading the next set of actions. const isLoadingInitialReportActions = _.isEmpty(this.props.reportActions) && this.props.report.isLoadingReportActions; + // Users not in the Default Room or Policy Room Betas can't view the report + const shouldHideReport = ( + ReportUtils.isDefaultRoom(this.props.report) && !ReportUtils.canSeeDefaultRoom(this.props.report, this.props.policies, this.props.betas)) + || (ReportUtils.isUserCreatedPolicyRoom(this.props.report) && !Permissions.canUsePolicyRooms(this.props.betas)); + // When the ReportScreen is not open/in the viewport, we want to "freeze" it for performance reasons const shouldFreeze = this.props.isSmallScreenWidth && this.props.isDrawerOpen; @@ -244,7 +241,7 @@ class ReportScreen extends React.Component { )} >