Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion src/libs/PolicyUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,12 @@ function isExpensifyTeam(email) {
return emailDomain === CONST.EXPENSIFY_PARTNER_NAME || emailDomain === CONST.EMAIL.GUIDES_DOMAIN;
}

export {hasPolicyMemberError, hasPolicyError, hasPolicyErrorFields, hasCustomUnitsError, getPolicyBrickRoadIndicatorStatus, shouldShowPolicy, isExpensifyTeam};
/**
* Checks if the current user is an admin of the policy.
*
* @param {Object} policy
* @returns {Boolean}
*/
const isPolicyAdmin = (policy) => lodashGet(policy, 'role') === CONST.POLICY.ROLE.ADMIN;

export {hasPolicyMemberError, hasPolicyError, hasPolicyErrorFields, hasCustomUnitsError, getPolicyBrickRoadIndicatorStatus, shouldShowPolicy, isExpensifyTeam, isPolicyAdmin};
35 changes: 27 additions & 8 deletions src/pages/ReportDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import {View, ScrollView} from 'react-native';
import {View, ScrollView, Pressable} from 'react-native';
import lodashGet from 'lodash/get';
import RoomHeaderAvatars from '../components/RoomHeaderAvatars';
import compose from '../libs/compose';
Expand All @@ -15,6 +15,7 @@ import styles from '../styles/styles';
import DisplayNames from '../components/DisplayNames';
import * as OptionsListUtils from '../libs/OptionsListUtils';
import * as ReportUtils from '../libs/ReportUtils';
import * as PolicyUtils from '../libs/PolicyUtils';
import * as Report from '../libs/actions/Report';
import participantPropTypes from '../components/participantPropTypes';
import * as Expensicons from '../components/Icon/Expensicons';
Expand Down Expand Up @@ -56,6 +57,10 @@ const defaultProps = {
};

class ReportDetailsPage extends Component {
getPolicy() {
return this.props.policies[`${ONYXKEYS.COLLECTION.POLICY}${this.props.report.policyID}`];
}

getMenuItems() {
const menuItems = [
{
Expand Down Expand Up @@ -93,7 +98,7 @@ class ReportDetailsPage extends Component {
});
}

const policy = this.props.policies[`${ONYXKEYS.COLLECTION.POLICY}${this.props.report.policyID}`];
const policy = this.getPolicy();
const isThread = ReportUtils.isThread(this.props.report);
if (ReportUtils.isUserCreatedPolicyRoom(this.props.report) || ReportUtils.canLeaveRoom(this.props.report, !_.isEmpty(policy)) || isThread) {
menuItems.push({
Expand All @@ -119,6 +124,15 @@ class ReportDetailsPage extends Component {
isMultipleParticipant,
);
const menuItems = this.getMenuItems();
const isPolicyAdmin = PolicyUtils.isPolicyAdmin(this.getPolicy());
const chatRoomSubtitleText = (
<Text
style={[styles.sidebarLinkText, styles.optionAlternateText, styles.textLabelSupporting, styles.mb2, styles.pre]}
numberOfLines={1}
>
{chatRoomSubtitle}
</Text>
);
return (
<ScreenWrapper>
<FullPageNotFoundView shouldShow={_.isEmpty(this.props.report)}>
Expand All @@ -144,12 +158,17 @@ class ReportDetailsPage extends Component {
shouldUseFullTitle={isChatRoom || isPolicyExpenseChat || isThread}
/>
</View>
<Text
style={[styles.sidebarLinkText, styles.optionAlternateText, styles.textLabelSupporting, styles.mb2, styles.pre]}
numberOfLines={1}
>
{chatRoomSubtitle}
</Text>
{isPolicyAdmin ? (
<Pressable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from #23355, we should have taken into account the scenario in which the workspace has a pending delete action, and consequently, disable navigation to that workspace.

onPress={() => {
Navigation.navigate(ROUTES.getWorkspaceInitialRoute(this.props.report.policyID));
Comment thread
alitoshmatov marked this conversation as resolved.
Resolved
}}
>
{chatRoomSubtitleText}
</Pressable>
) : (
chatRoomSubtitleText
)}
</View>
</View>
</View>
Expand Down