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
5 changes: 5 additions & 0 deletions src/libs/SubscriptionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
};

let deprecatedCurrentUserAccountID = -1;
Onyx.connect({

Check warning on line 56 in src/libs/SubscriptionUtils.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.SESSION,
callback: (value) => {
deprecatedCurrentUserAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID;
Expand All @@ -61,7 +61,7 @@
});

let deprecatedAllPolicies: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 64 in src/libs/SubscriptionUtils.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,
callback: (value) => (deprecatedAllPolicies = value),
waitForCollectionCallback: true,
Expand Down Expand Up @@ -515,6 +515,10 @@
return CONST.SUBSCRIPTION_PRICES[preferredCurrency][plan][privateSubscriptionType];
}

function shouldUseSimplifiedCollectSubscriptionUI(plan: PersonalPolicyTypeExcludedProps | null, hasTeam2025Pricing: boolean): boolean {
return plan === CONST.POLICY.TYPE.TEAM && hasTeam2025Pricing;
}

function getSubscriptionPlanInfo(
translate: LocalizedTranslate,
subscriptionPlan: PersonalPolicyTypeExcludedProps | null,
Expand Down Expand Up @@ -629,6 +633,7 @@
shouldCalculateBillNewDot,
getSubscriptionPlanInfo,
getSubscriptionPrice,
shouldUseSimplifiedCollectSubscriptionUI,
shouldShowTrialEndedUI,
isSubscriptionTypeOfInvoicing,
hasInsufficientFundsError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {openLink} from '@libs/actions/Link';
import {convertToShortDisplayString} from '@libs/CurrencyUtils';
import {isPolicyAdmin} from '@libs/PolicyUtils';
import {getSubscriptionPrice, isSubscriptionTypeOfInvoicing} from '@libs/SubscriptionUtils';
import {getSubscriptionPrice, isSubscriptionTypeOfInvoicing, shouldUseSimplifiedCollectSubscriptionUI} from '@libs/SubscriptionUtils';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import Navigation from '@navigation/Navigation';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
Expand Down Expand Up @@ -53,7 +53,7 @@ function SubscriptionSettings() {
upper: convertToShortDisplayString(subscriptionPrice * CONST.SUBSCRIPTION_PRICE_FACTOR, preferredCurrency),
});
const adminsChatReportID = isActivePolicyAdmin && activePolicy?.chatReportIDAdmins ? activePolicy.chatReportIDAdmins?.toString() : undefined;
const isCollect = subscriptionPlan === CONST.POLICY.TYPE.TEAM;
const shouldUseSimplifiedCollectUI = shouldUseSimplifiedCollectSubscriptionUI(subscriptionPlan, hasTeam2025Pricing);
const collectPriceDisplay = convertToShortDisplayString(subscriptionPrice, preferredCurrency);

const openAdminsRoom = () => {
Expand Down Expand Up @@ -100,7 +100,7 @@ function SubscriptionSettings() {
/>
<ScrollView contentContainerStyle={[styles.flexGrow1, styles.ph5]}>
<Text style={[styles.textSupporting, styles.mb5]}>{translate('subscription.mobileReducedFunctionalityMessage')}</Text>
{isCollect ? (
{shouldUseSimplifiedCollectUI ? (
<>
<Text style={[styles.textSupporting, styles.mb5]}>{translate('subscription.subscriptionSettings.collectBillingDescription')}</Text>
<View style={[styles.renderHTML, styles.mb5]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {openLink} from '@libs/actions/Link';
import {convertToDisplayString, convertToShortDisplayString} from '@libs/CurrencyUtils';
import {isPolicyAdmin} from '@libs/PolicyUtils';
import {getSubscriptionPrice, isSubscriptionTypeOfInvoicing} from '@libs/SubscriptionUtils';
import {getSubscriptionPrice, isSubscriptionTypeOfInvoicing, shouldUseSimplifiedCollectSubscriptionUI} from '@libs/SubscriptionUtils';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import Navigation from '@navigation/Navigation';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
Expand Down Expand Up @@ -89,7 +89,7 @@ function SubscriptionSettings() {
upper: convertToShortDisplayString(subscriptionPrice * CONST.SUBSCRIPTION_PRICE_FACTOR, preferredCurrency),
});
const adminsChatReportID = isActivePolicyAdmin && activePolicy?.chatReportIDAdmins ? activePolicy.chatReportIDAdmins?.toString() : undefined;
const isCollect = subscriptionPlan === CONST.POLICY.TYPE.TEAM;
const shouldUseSimplifiedCollectUI = shouldUseSimplifiedCollectSubscriptionUI(subscriptionPlan, hasTeam2025Pricing);
const collectPriceDisplay = convertToShortDisplayString(subscriptionPrice, preferredCurrency);

const onOptionSelected = (option: SubscriptionType) => {
Expand Down Expand Up @@ -232,7 +232,7 @@ function SubscriptionSettings() {
onBackButtonPress={() => Navigation.goBack()}
/>
<ScrollView contentContainerStyle={[styles.flexGrow1, styles.ph5]}>
{isCollect ? (
{shouldUseSimplifiedCollectUI ? (
<>
<Text style={[styles.textSupporting, styles.mb5]}>{translate('subscription.subscriptionSettings.collectBillingDescription')}</Text>
<View style={[styles.renderHTML, styles.mb5]}>
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/SubscriptionUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
shouldShowDiscountBanner,
shouldShowPreTrialBillingBanner,
shouldShowTrialEndedUI,
shouldUseSimplifiedCollectSubscriptionUI,
} from '@libs/SubscriptionUtils';
import {getPrivatePromoDiscountInfo} from '@pages/settings/Subscription/utils';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -1100,6 +1101,24 @@ describe('SubscriptionUtils', () => {
});
});

describe('shouldUseSimplifiedCollectSubscriptionUI', () => {
it('returns true for Team workspaces with Team 2025 pricing', () => {
expect(shouldUseSimplifiedCollectSubscriptionUI(CONST.POLICY.TYPE.TEAM, true)).toBeTruthy();
});

it('returns false for Team workspaces without Team 2025 pricing', () => {
expect(shouldUseSimplifiedCollectSubscriptionUI(CONST.POLICY.TYPE.TEAM, false)).toBeFalsy();
});

it('returns false for Corporate workspaces without Team 2025 pricing', () => {
expect(shouldUseSimplifiedCollectSubscriptionUI(CONST.POLICY.TYPE.CORPORATE, false)).toBeFalsy();
});

it('returns false for Corporate workspaces with Team 2025 pricing', () => {
expect(shouldUseSimplifiedCollectSubscriptionUI(CONST.POLICY.TYPE.CORPORATE, true)).toBeFalsy();
});
});

describe('getEarlyDiscountInfo', () => {
const TEST_DATE = new Date();

Expand Down
Loading