Skip to content

Commit

Permalink
Merge pull request Expensify#26982 from Expensify/jasper-updatePolicy…
Browse files Browse the repository at this point in the history
…Type

Update policy type definitions and use `areChatRoomsEnabled` flag
  • Loading branch information
jasperhuangg authored Sep 21, 2023
2 parents bb32cc5 + b64ece2 commit 65fd435
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/libs/PolicyUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import ONYXKEYS from '../ONYXKEYS';

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

/**
Expand Down
27 changes: 21 additions & 6 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,49 @@ import * as OnyxCommon from './OnyxCommon';

type Policy = {
/** The ID of the policy */
id?: string;
id: string;

/** The name of the policy */
name?: string;
name: string;

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

/** The policy type */
type?: ValueOf<typeof CONST.POLICY.TYPE>;
type: ValueOf<typeof CONST.POLICY.TYPE>;

/** The email of the policy owner */
owner?: string;
owner: string;

/** The output currency for the policy */
outputCurrency?: string;
outputCurrency: string;

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

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

/** Indicates the type of change made to the policy that hasn't been synced with the server yet */
pendingAction?: OnyxCommon.PendingAction;

/** A list of errors keyed by microtime */
errors: OnyxCommon.Errors;

/** Whether this policy was loaded from a policy summary, or loaded completely with all of its values */
isFromFullPolicy?: boolean;

/** When this policy was last modified */
lastModified?: string;

/** The custom units data for this policy */
customUnits?: Record<string, unknown>;

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

export default Policy;

0 comments on commit 65fd435

Please sign in to comment.