Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update policy type definitions and use areChatRoomsEnabled flag #26982

Merged
merged 6 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
}

/**
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;
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
};

export default Policy;
Loading