Skip to content

Commit

Permalink
Merge branch 'main' into fix/21392
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenv0307 committed Jan 11, 2024
2 parents 3b93bf2 + 8ecc11a commit fe22006
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ 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.isPolicyExpenseChatEnabled || policy.areChatRoomsEnabled) && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RoomInvitePage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {parsePhoneNumber} from 'awesome-phonenumber';
import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
Expand All @@ -19,6 +18,7 @@ import * as LoginUtils from '@libs/LoginUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import {parsePhoneNumber} from '@libs/PhoneNumber';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as Report from '@userActions/Report';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {parsePhoneNumber} from 'awesome-phonenumber';
import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
Expand All @@ -19,6 +18,7 @@ import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import * as LoginUtils from '@libs/LoginUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import {parsePhoneNumber} from '@libs/PhoneNumber';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as Policy from '@userActions/Policy';
import CONST from '@src/CONST';
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ 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: 1 addition & 0 deletions tests/utils/LHNTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ function getFakePolicy(id = 1, name = 'Workspace-Test-001') {
avatar: '',
employeeList: [],
isPolicyExpenseChatEnabled: true,
areChatRoomsEnabled: true,
lastModified: 1697323926777105,
autoReporting: true,
autoReportingFrequency: 'immediate',
Expand Down
1 change: 1 addition & 0 deletions tests/utils/collections/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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 fe22006

Please sign in to comment.