From b5a6d3584bfdd851d10a2b42d3321abaa65ffcc9 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Tue, 1 Aug 2023 22:25:30 +0100 Subject: [PATCH 1/4] Display NVP-enabled control policies in NewDot --- src/libs/PolicyUtils.js | 11 +++++++++-- .../SidebarScreen/FloatingActionButtonAndPopover.js | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libs/PolicyUtils.js b/src/libs/PolicyUtils.js index 582271d6610e..0de7f5137e8b 100644 --- a/src/libs/PolicyUtils.js +++ b/src/libs/PolicyUtils.js @@ -10,7 +10,14 @@ import ONYXKEYS from '../ONYXKEYS'; * @returns {Array} */ function getActivePolicies(policies) { - return _.filter(policies, (policy) => policy && policy.type === CONST.POLICY.TYPE.FREE && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); + return _.filter(policies, (policy) => { + console.log(policy); + return ( + policy && + (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isControlWorkspaceEnabled)) && + policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE + ); + }); } /** @@ -86,7 +93,7 @@ function getPolicyBrickRoadIndicatorStatus(policy, policyMembersCollection) { function shouldShowPolicy(policy, isOffline) { return ( policy && - policy.type === CONST.POLICY.TYPE.FREE && + (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isControlWorkspaceEnabled)) && policy.role === CONST.POLICY.ROLE.ADMIN && (isOffline || policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !_.isEmpty(policy.errors)) ); diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 1ccdf9261b19..a4b313c569ba 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -36,6 +36,7 @@ const policySelector = (policy) => policy && { type: policy.type, role: policy.role, + isControlWorkspaceEnabled: policy.isControlWorkspaceEnabled, pendingAction: policy.pendingAction, }; @@ -174,6 +175,7 @@ function FloatingActionButtonAndPopover(props) { })); const workspaces = PolicyUtils.getActivePolicies(props.allPolicies); + console.log('w', workspaces); return ( From 6602a92261982c970397f5c0c761552f4d51c703 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Fri, 4 Aug 2023 18:48:47 +0100 Subject: [PATCH 2/4] Update policy flag name --- src/libs/PolicyUtils.js | 4 ++-- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/PolicyUtils.js b/src/libs/PolicyUtils.js index 0de7f5137e8b..9d2c28a58573 100644 --- a/src/libs/PolicyUtils.js +++ b/src/libs/PolicyUtils.js @@ -14,7 +14,7 @@ function getActivePolicies(policies) { console.log(policy); return ( policy && - (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isControlWorkspaceEnabled)) && + (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isPolicyExpenseChatEnabled)) && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ); }); @@ -93,7 +93,7 @@ function getPolicyBrickRoadIndicatorStatus(policy, policyMembersCollection) { function shouldShowPolicy(policy, isOffline) { return ( policy && - (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isControlWorkspaceEnabled)) && + (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isPolicyExpenseChatEnabled)) && policy.role === CONST.POLICY.ROLE.ADMIN && (isOffline || policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !_.isEmpty(policy.errors)) ); diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index a4b313c569ba..6ddbf8d0822f 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -36,7 +36,7 @@ const policySelector = (policy) => policy && { type: policy.type, role: policy.role, - isControlWorkspaceEnabled: policy.isControlWorkspaceEnabled, + isPolicyExpenseChatEnabled: policy.isPolicyExpenseChatEnabled, pendingAction: policy.pendingAction, }; From fbc70a0bac00f6a438e056425989760ffece2ff0 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Fri, 4 Aug 2023 19:43:53 +0100 Subject: [PATCH 3/4] clean up --- src/libs/PolicyUtils.js | 11 +++++------ .../SidebarScreen/FloatingActionButtonAndPopover.js | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/libs/PolicyUtils.js b/src/libs/PolicyUtils.js index 9d2c28a58573..89cc183f496c 100644 --- a/src/libs/PolicyUtils.js +++ b/src/libs/PolicyUtils.js @@ -10,14 +10,13 @@ import ONYXKEYS from '../ONYXKEYS'; * @returns {Array} */ function getActivePolicies(policies) { - return _.filter(policies, (policy) => { - console.log(policy); - return ( + return _.filter( + policies, + (policy) => policy && (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isPolicyExpenseChatEnabled)) && - policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE - ); - }); + policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, + ); } /** diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 6ddbf8d0822f..dc73ba956838 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -175,7 +175,6 @@ function FloatingActionButtonAndPopover(props) { })); const workspaces = PolicyUtils.getActivePolicies(props.allPolicies); - console.log('w', workspaces); return ( From 286f8c26e22afb96baf516af040b38834a9a3f7b Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Tue, 8 Aug 2023 21:28:57 +0100 Subject: [PATCH 4/4] Use isPolicyExpenseChatEnabled --- src/libs/PolicyUtils.js | 10 ++-------- src/libs/actions/Policy.js | 1 + 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/libs/PolicyUtils.js b/src/libs/PolicyUtils.js index 89cc183f496c..164f284a4ef5 100644 --- a/src/libs/PolicyUtils.js +++ b/src/libs/PolicyUtils.js @@ -10,13 +10,7 @@ import ONYXKEYS from '../ONYXKEYS'; * @returns {Array} */ function getActivePolicies(policies) { - return _.filter( - policies, - (policy) => - policy && - (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isPolicyExpenseChatEnabled)) && - policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, - ); + return _.filter(policies, (policy) => policy && policy.isPolicyExpenseChatEnabled && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); } /** @@ -92,7 +86,7 @@ function getPolicyBrickRoadIndicatorStatus(policy, policyMembersCollection) { function shouldShowPolicy(policy, isOffline) { return ( policy && - (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isPolicyExpenseChatEnabled)) && + policy.isPolicyExpenseChatEnabled && policy.role === CONST.POLICY.ROLE.ADMIN && (isOffline || policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !_.isEmpty(policy.errors)) ); diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 4a58f52eff0a..93621a517ee3 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -906,6 +906,7 @@ function createWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policyName name: workspaceName, role: CONST.POLICY.ROLE.ADMIN, owner: sessionEmail, + isPolicyExpenseChatEnabled: true, outputCurrency: lodashGet(allPersonalDetails, [sessionAccountID, 'localCurrencyCode'], CONST.CURRENCY.USD), pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, },