From cf691f46881595605e8bef0a86bbd91459037928 Mon Sep 17 00:00:00 2001 From: Ionatan Wiznia Date: Thu, 1 Feb 2024 18:20:46 +0100 Subject: [PATCH 1/3] Revert "[CP Staging] Revert "[NO QA] Remove areChatRoomsEnabled checks"" --- src/libs/PolicyUtils.ts | 5 +---- src/types/onyx/Policy.ts | 3 --- tests/utils/LHNTestUtils.js | 1 - tests/utils/collections/policies.ts | 1 - 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index b8ed62f93082..5a8fe907d479 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -15,10 +15,7 @@ type UnitRate = {rate: number}; * These are policies that we can use to create reports with in NewDot. */ function getActivePolicies(policies: OnyxCollection): Policy[] | undefined { - return Object.values(policies ?? {}).filter( - (policy): policy is Policy => - policy !== null && policy && (policy.isPolicyExpenseChatEnabled || policy.areChatRoomsEnabled) && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, - ); + return Object.values(policies ?? {}).filter((policy): policy is Policy => policy !== null && policy && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); } /** diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index fe50bbb497d2..39c5f5e9c78e 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -76,9 +76,6 @@ type Policy = { /** The custom units data for this policy */ customUnits?: Record; - /** Whether chat rooms can be created and used on this policy. Enabled manually by CQ/JS snippet. Always true for free policies. */ - areChatRoomsEnabled: boolean; - /** Whether policy expense chats can be created and used on this policy. Enabled manually by CQ/JS snippet. Always true for free policies. */ isPolicyExpenseChatEnabled: boolean; diff --git a/tests/utils/LHNTestUtils.js b/tests/utils/LHNTestUtils.js index 04246c1c438a..3e40063dd040 100644 --- a/tests/utils/LHNTestUtils.js +++ b/tests/utils/LHNTestUtils.js @@ -252,7 +252,6 @@ function getFakePolicy(id = 1, name = 'Workspace-Test-001') { avatar: '', employeeList: [], isPolicyExpenseChatEnabled: true, - areChatRoomsEnabled: true, lastModified: 1697323926777105, autoReporting: true, autoReportingFrequency: 'immediate', diff --git a/tests/utils/collections/policies.ts b/tests/utils/collections/policies.ts index 4223c7e41941..7ecf152122d3 100644 --- a/tests/utils/collections/policies.ts +++ b/tests/utils/collections/policies.ts @@ -7,7 +7,6 @@ export default function createRandomPolicy(index: number): Policy { id: index.toString(), name: randWord(), type: rand(Object.values(CONST.POLICY.TYPE)), - areChatRoomsEnabled: randBoolean(), autoReporting: randBoolean(), isPolicyExpenseChatEnabled: randBoolean(), autoReportingFrequency: rand(Object.values(CONST.POLICY.AUTO_REPORTING_FREQUENCIES)), From db8de4dfe3fb2ab5f8ccb7ff4750c7c7862b35a1 Mon Sep 17 00:00:00 2001 From: Ionatan Wiznia Date: Thu, 1 Feb 2024 14:22:55 -0300 Subject: [PATCH 2/3] Remove more usages --- src/libs/actions/Policy.ts | 3 --- src/libs/actions/TeachersUnite.ts | 1 - 2 files changed, 4 deletions(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index fbe92aeb378d..dfc5f4c705b8 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -1160,7 +1160,6 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol isPolicyExpenseChatEnabled: true, outputCurrency, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, - areChatRoomsEnabled: true, customUnits, makeMeAdmin, }, @@ -1221,7 +1220,6 @@ function createWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policyName isPolicyExpenseChatEnabled: true, outputCurrency, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, - areChatRoomsEnabled: true, customUnits, }, }, @@ -1600,7 +1598,6 @@ function createWorkspaceFromIOUPayment(iouReport: Report): string | undefined { // Setting the currency to USD as we can only add the VBBA for this policy currency right now outputCurrency: CONST.CURRENCY.USD, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, - areChatRoomsEnabled: true, customUnits, }; diff --git a/src/libs/actions/TeachersUnite.ts b/src/libs/actions/TeachersUnite.ts index 055d1f2b53a2..ab48609e2d53 100644 --- a/src/libs/actions/TeachersUnite.ts +++ b/src/libs/actions/TeachersUnite.ts @@ -91,7 +91,6 @@ function addSchoolPrincipal(firstName: string, partnerUserID: string, lastName: value: { id: policyID, isPolicyExpenseChatEnabled: true, - areChatRoomsEnabled: true, type: CONST.POLICY.TYPE.CORPORATE, name: policyName, role: CONST.POLICY.ROLE.USER, From 18796cc55342f0d6017bbfd9bd5e5e74b49d710b Mon Sep 17 00:00:00 2001 From: Ionatan Wiznia Date: Fri, 2 Feb 2024 12:10:42 -0300 Subject: [PATCH 3/3] Filter out personal policies in room page --- src/pages/workspace/WorkspaceNewRoomPage.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/WorkspaceNewRoomPage.js b/src/pages/workspace/WorkspaceNewRoomPage.js index b616b519ff32..fa128b2bfce6 100644 --- a/src/pages/workspace/WorkspaceNewRoomPage.js +++ b/src/pages/workspace/WorkspaceNewRoomPage.js @@ -106,11 +106,14 @@ function WorkspaceNewRoomPage(props) { const workspaceOptions = useMemo( () => - _.map(PolicyUtils.getActivePolicies(props.policies), (policy) => ({ - label: policy.name, - key: policy.id, - value: policy.id, - })), + _.map( + _.filter(PolicyUtils.getActivePolicies(props.policies), (policy) => policy.type !== CONST.POLICY.TYPE.PERSONAL), + (policy) => ({ + label: policy.name, + key: policy.id, + value: policy.id, + }), + ), [props.policies], ); const [policyID, setPolicyID] = useState(() => {