Skip to content
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
6 changes: 3 additions & 3 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

let allPolicies: OnyxCollection<Policy>;

Onyx.connect({

Check warning on line 61 in src/libs/PolicyUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
Expand Down Expand Up @@ -1419,15 +1419,15 @@
);
}

function areAllGroupPoliciesExpenseChatDisabled(policies = allPolicies) {
const groupPolicies = Object.values(policies ?? {}).filter((policy) => isPaidGroupPolicy(policy));
function areAllGroupPoliciesExpenseChatDisabled(policies: OnyxCollection<Policy> | null) {
const groupPolicies = Object.values(policies ?? {}).filter(isPaidGroupPolicy);
if (groupPolicies.length === 0) {
return false;
}
return !groupPolicies.some((policy) => !!policy?.isPolicyExpenseChatEnabled);
}

function getGroupPaidPoliciesWithExpenseChatEnabled(policies: OnyxCollection<Policy> | null = allPolicies) {
function getGroupPaidPoliciesWithExpenseChatEnabled(policies: OnyxCollection<Policy> | null) {
if (isEmptyObject(policies)) {
return CONST.EMPTY_ARRAY;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function EmptySearchView({similarSearchHash, type, hasResults}: EmptySearchViewP
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`, {canBeMissing: true});

const groupPoliciesWithChatEnabled = getGroupPaidPoliciesWithExpenseChatEnabled();
const groupPoliciesWithChatEnabled = useMemo(() => getGroupPaidPoliciesWithExpenseChatEnabled(allPolicies), [allPolicies]);

const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true});
const [hasSeenTour = false] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref
} = useOnboardingTaskInformation(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR);

const isReportInSearch = isOnSearchMoneyRequestReportPage();
const groupPoliciesWithChatEnabled = getGroupPaidPoliciesWithExpenseChatEnabled();
const groupPoliciesWithChatEnabled = getGroupPaidPoliciesWithExpenseChatEnabled(allPolicies as OnyxCollection<OnyxTypes.Policy>);

/**
* There are scenarios where users who have not yet had their group workspace-chats in NewDot (isPolicyExpenseChatEnabled). In those scenarios, things can get confusing if they try to submit/track expenses. To address this, we block them from Creating, Tracking, Submitting expenses from NewDot if they are:
Expand Down
Loading