diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index b7542b160fb1..46cc71850ccb 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -66,12 +66,6 @@ Onyx.connect({ callback: (val) => (allPersonalDetails = val), }); -let loginList; -Onyx.connect({ - key: ONYXKEYS.LOGIN_LIST, - callback: (val) => (loginList = val), -}); - /** * Stores in Onyx the policy ID of the last workspace that was accessed by the user * @param {String|null} policyID @@ -161,16 +155,6 @@ function isAdminOfFreePolicy(policies) { return _.some(policies, (policy) => policy && policy.type === CONST.POLICY.TYPE.FREE && policy.role === CONST.POLICY.ROLE.ADMIN); } -/** - * Is the user the owner of the given policy? - * - * @param {Object} policy - * @returns {Boolean} - */ -function isPolicyOwner(policy) { - return _.keys(loginList).includes(policy.owner); -} - /** * Check if the user has any active free policies (aka workspaces) * @@ -1201,6 +1185,5 @@ export { openWorkspaceInvitePage, removeWorkspace, setWorkspaceInviteMembersDraft, - isPolicyOwner, clearErrors, }; diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index fafcb2c94f8c..a83ab4a42080 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -32,7 +32,7 @@ import * as ReimbursementAccountProps from './reimbursementAccountPropTypes'; import reimbursementAccountDraftPropTypes from './ReimbursementAccountDraftPropTypes'; import withPolicy from '../workspace/withPolicy'; import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView'; -import * as Policy from '../../libs/actions/Policy'; +import * as PolicyUtils from '../../libs/PolicyUtils'; const propTypes = { /** Plaid SDK token to use to initialize the widget */ @@ -332,7 +332,7 @@ class ReimbursementAccountPage extends React.Component { const policyName = lodashGet(this.props.policy, 'name'); const policyID = lodashGet(this.props.route.params, 'policyID'); - if (_.isEmpty(this.props.policy) || !Policy.isPolicyOwner(this.props.policy)) { + if (_.isEmpty(this.props.policy) || !PolicyUtils.isPolicyAdmin(this.props.policy)) { return ( ( Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} - shouldShow={_.isEmpty(props.policy) || !Policy.isPolicyOwner(props.policy)} + shouldShow={_.isEmpty(props.policy) || !PolicyUtils.isPolicyAdmin(props.policy)} subtitleKey={_.isEmpty(props.policy) ? undefined : 'workspace.common.notAuthorized'} > Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} > diff --git a/src/pages/workspace/WorkspaceInvitePage.js b/src/pages/workspace/WorkspaceInvitePage.js index bff4a55d94a0..6a49e043a54a 100644 --- a/src/pages/workspace/WorkspaceInvitePage.js +++ b/src/pages/workspace/WorkspaceInvitePage.js @@ -201,7 +201,7 @@ function WorkspaceInvitePage(props) { const sections = didScreenTransitionEnd ? getSections() : []; return ( Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} > diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index 154a337ee5a6..64cd9d319beb 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -405,7 +405,7 @@ function WorkspaceMembersPage(props) { > {({safeAreaPaddingBottomStyle}) => ( Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} > diff --git a/src/pages/workspace/WorkspacePageWithSections.js b/src/pages/workspace/WorkspacePageWithSections.js index 801277b89c9a..fa04f5cfc49e 100644 --- a/src/pages/workspace/WorkspacePageWithSections.js +++ b/src/pages/workspace/WorkspacePageWithSections.js @@ -5,8 +5,8 @@ import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; import _ from 'underscore'; import styles from '../../styles/styles'; +import * as PolicyUtils from '../../libs/PolicyUtils'; import Navigation from '../../libs/Navigation/Navigation'; -import * as Policy from '../../libs/actions/Policy'; import compose from '../../libs/compose'; import ROUTES from '../../ROUTES'; import HeaderWithBackButton from '../../components/HeaderWithBackButton'; @@ -105,7 +105,7 @@ function WorkspacePageWithSections({backButtonRoute, children, footer, guidesCal > Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} - shouldShow={_.isEmpty(policy) || !Policy.isPolicyOwner(policy)} + shouldShow={_.isEmpty(policy) || !PolicyUtils.isPolicyAdmin(policy)} subtitleKey={_.isEmpty(policy) ? undefined : 'workspace.common.notAuthorized'} >