Skip to content

Commit

Permalink
Merge pull request #35576 from Expensify/revert-34311-revert-34046-io…
Browse files Browse the repository at this point in the history
…natan_killareChatRoomsEnabled

Revert "[CP Staging] Revert "[NO QA] Remove areChatRoomsEnabled checks""
  • Loading branch information
techievivek authored Feb 5, 2024
2 parents 8034a1b + 18796cc commit 1747e86
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 18 deletions.
5 changes: 1 addition & 4 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>): Policy[] | undefined {
return Object.values(policies ?? {}).filter<Policy>(
(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): policy is Policy => policy !== null && policy && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
}

/**
Expand Down
3 changes: 0 additions & 3 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,6 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol
isPolicyExpenseChatEnabled: true,
outputCurrency,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
areChatRoomsEnabled: true,
customUnits,
makeMeAdmin,
},
Expand Down Expand Up @@ -1223,7 +1222,6 @@ function createWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policyName
isPolicyExpenseChatEnabled: true,
outputCurrency,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
areChatRoomsEnabled: true,
customUnits,
},
},
Expand Down Expand Up @@ -1603,7 +1601,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,
};

Expand Down
1 change: 0 additions & 1 deletion src/libs/actions/TeachersUnite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 8 additions & 5 deletions src/pages/workspace/WorkspaceNewRoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
3 changes: 0 additions & 3 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ type Policy = {
/** The custom units data for this policy */
customUnits?: Record<string, CustomUnit>;

/** 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;

Expand Down
1 change: 0 additions & 1 deletion tests/utils/LHNTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ function getFakePolicy(id = 1, name = 'Workspace-Test-001') {
avatar: '',
employeeList: [],
isPolicyExpenseChatEnabled: true,
areChatRoomsEnabled: true,
lastModified: 1697323926777105,
autoReporting: true,
autoReportingFrequency: 'immediate',
Expand Down
1 change: 0 additions & 1 deletion tests/utils/collections/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 1747e86

Please sign in to comment.