Skip to content

Commit 65fd435

Browse files
authored
Merge pull request #26982 from Expensify/jasper-updatePolicyType
Update policy type definitions and use `areChatRoomsEnabled` flag
2 parents bb32cc5 + b64ece2 commit 65fd435

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/libs/PolicyUtils.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import ONYXKEYS from '../ONYXKEYS';
66

77
/**
88
* Filter out the active policies, which will exclude policies with pending deletion
9+
* These are policies that we can use to create reports with in NewDot.
910
* @param {Object} policies
1011
* @returns {Array}
1112
*/
1213
function getActivePolicies(policies) {
13-
return _.filter(policies, (policy) => policy && policy.isPolicyExpenseChatEnabled && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
14+
return _.filter(policies, (policy) => policy && (policy.isPolicyExpenseChatEnabled || policy.areChatRoomsEnabled) && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
1415
}
1516

1617
/**

src/types/onyx/Policy.ts

+21-6
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,49 @@ import * as OnyxCommon from './OnyxCommon';
44

55
type Policy = {
66
/** The ID of the policy */
7-
id?: string;
7+
id: string;
88

99
/** The name of the policy */
10-
name?: string;
10+
name: string;
1111

1212
/** The current user's role in the policy */
13-
role?: ValueOf<typeof CONST.POLICY.ROLE>;
13+
role: ValueOf<typeof CONST.POLICY.ROLE>;
1414

1515
/** The policy type */
16-
type?: ValueOf<typeof CONST.POLICY.TYPE>;
16+
type: ValueOf<typeof CONST.POLICY.TYPE>;
1717

1818
/** The email of the policy owner */
19-
owner?: string;
19+
owner: string;
2020

2121
/** The output currency for the policy */
22-
outputCurrency?: string;
22+
outputCurrency: string;
2323

2424
/** The URL for the policy avatar */
2525
avatar?: string;
2626

2727
/** Error objects keyed by field name containing errors keyed by microtime */
2828
errorFields?: OnyxCommon.ErrorFields;
2929

30+
/** Indicates the type of change made to the policy that hasn't been synced with the server yet */
3031
pendingAction?: OnyxCommon.PendingAction;
32+
33+
/** A list of errors keyed by microtime */
3134
errors: OnyxCommon.Errors;
35+
36+
/** Whether this policy was loaded from a policy summary, or loaded completely with all of its values */
3237
isFromFullPolicy?: boolean;
38+
39+
/** When this policy was last modified */
3340
lastModified?: string;
41+
42+
/** The custom units data for this policy */
3443
customUnits?: Record<string, unknown>;
44+
45+
/** Whether chat rooms can be created and used on this policy. Enabled manually by CQ/JS snippet. Always true for free policies. */
46+
areChatRoomsEnabled: boolean;
47+
48+
/** Whether policy expense chats can be created and used on this policy. Enabled manually by CQ/JS snippet. Always true for free policies. */
49+
isPolicyExpenseChatEnabled: boolean;
3550
};
3651

3752
export default Policy;

0 commit comments

Comments
 (0)