Skip to content
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
15 changes: 6 additions & 9 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

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