Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhenjaHorbach committed Feb 9, 2024
1 parent faf8973 commit 78bbc35
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>): Policy[] | undefined {
return Object.values(policies ?? {}).filter<Policy>((policy): policy is Policy => policy !== null && policy && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
return Object.values(policies ?? {}).filter<Policy>(
(policy): policy is Policy => policy !== null && policy && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !!policy.name && !!policy.id,
);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/pages/workspace/WorkspaceNewRoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 78bbc35

Please sign in to comment.