From 78bbc3531a8ccf817596c4acc759a142ec167e04 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Fri, 9 Feb 2024 23:05:43 +0100 Subject: [PATCH] Refactor code --- src/libs/PolicyUtils.ts | 4 +++- src/pages/workspace/WorkspaceNewRoomPage.js | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 0575e297da0c..a3729ef81fe4 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -15,7 +15,9 @@ 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.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 && !!policy.name && !!policy.id, + ); } /** diff --git a/src/pages/workspace/WorkspaceNewRoomPage.js b/src/pages/workspace/WorkspaceNewRoomPage.js index c90b85d970f4..c140874e5a50 100644 --- a/src/pages/workspace/WorkspaceNewRoomPage.js +++ b/src/pages/workspace/WorkspaceNewRoomPage.js @@ -108,10 +108,7 @@ function WorkspaceNewRoomPage(props) { const workspaceOptions = useMemo( () => _.map( - _.filter( - _.filter(PolicyUtils.getActivePolicies(props.policies), (policy) => policy.type !== CONST.POLICY.TYPE.PERSONAL), - (policy) => policy.name && policy.id, - ), + _.filter(PolicyUtils.getActivePolicies(props.policies), (policy) => policy.type !== CONST.POLICY.TYPE.PERSONAL), (policy) => ({ label: policy.name, key: policy.id,