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
22 changes: 21 additions & 1 deletion src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7166,6 +7166,26 @@ const CONTINUATION_DETECTION_SEARCH_FILTER_KEYS = [
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTER,
] as SearchFilterKey[];

const FEATURE_IDS = {
CATEGORIES: 'categories',
ACCOUNTING: 'accounting',
COMPANY_CARDS: 'company-cards',
TAGS: 'tags',
WORKFLOWS: 'workflows',
INVOICES: 'invoices',
RULES: 'rules',
PER_DIEM: 'per-diem',
DISTANCE_RATES: 'distance-rates',
EXPENSIFY_CARD: 'expensify-card',
};

const TASK_TO_FEATURE: Record<string, string> = {
[CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES]: FEATURE_IDS.CATEGORIES,
[CONST.ONBOARDING_TASK_TYPE.ADD_ACCOUNTING_INTEGRATION]: FEATURE_IDS.ACCOUNTING,
[CONST.ONBOARDING_TASK_TYPE.CONNECT_CORPORATE_CARD]: FEATURE_IDS.COMPANY_CARDS,
[CONST.ONBOARDING_TASK_TYPE.SETUP_TAGS]: FEATURE_IDS.TAGS,
};

type Country = keyof typeof CONST.ALL_COUNTRIES;

type IOUType = ValueOf<typeof CONST.IOU.TYPE>;
Expand All @@ -7179,6 +7199,6 @@ type CancellationType = ValueOf<typeof CONST.CANCELLATION_TYPE>;

export type {Country, IOUAction, IOUType, IOURequestType, SubscriptionType, FeedbackSurveyOptionID, CancellationType, OnboardingInvite, OnboardingAccounting, IOUActionParams};

export {CONTINUATION_DETECTION_SEARCH_FILTER_KEYS};
export {CONTINUATION_DETECTION_SEARCH_FILTER_KEYS, TASK_TO_FEATURE, FEATURE_IDS};

export default CONST;
9 changes: 8 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {LocaleContextProps} from '@components/LocaleContextProvider';
import type {MoneyRequestAmountInputProps} from '@components/MoneyRequestAmountInput';
import type {FileObject} from '@pages/media/AttachmentModalScreen/types';
import type {IOUAction, IOUType, OnboardingAccounting} from '@src/CONST';
import CONST from '@src/CONST';
import CONST, {TASK_TO_FEATURE} from '@src/CONST';
import type {ParentNavigationSummaryParams} from '@src/languages/params';
import type {TranslationPaths} from '@src/languages/types';
import NAVIGATORS from '@src/NAVIGATORS';
Expand Down Expand Up @@ -10263,6 +10263,7 @@ function prepareOnboardingOnyxData(
userReportedIntegration?: OnboardingAccounting,
wasInvited?: boolean,
companySize?: OnboardingCompanySize,
selectedInterestedFeatures: string[] = [],
) {
if (engagementChoice === CONST.ONBOARDING_CHOICES.PERSONAL_SPEND) {
// eslint-disable-next-line no-param-reassign
Expand Down Expand Up @@ -10350,6 +10351,12 @@ function prepareOnboardingOnyxData(
let createWorkspaceTaskReportID;
const tasksData = onboardingMessage.tasks
.filter((task) => {
if (engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) {
if (selectedInterestedFeatures?.length && TASK_TO_FEATURE[task.type] && !selectedInterestedFeatures.includes(TASK_TO_FEATURE[task.type])) {
return false;
}
}

if (([CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES, CONST.ONBOARDING_TASK_TYPE.SETUP_TAGS] as string[]).includes(task.type) && userReportedIntegration) {
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4225,6 +4225,7 @@ function completeOnboarding({
companySize,
userReportedIntegration,
wasInvited,
selectedInterestedFeatures = [],
}: {
engagementChoice: OnboardingPurpose;
onboardingMessage: OnboardingMessage;
Expand All @@ -4236,6 +4237,7 @@ function completeOnboarding({
companySize?: OnboardingCompanySize;
userReportedIntegration?: OnboardingAccounting;
wasInvited?: boolean;
selectedInterestedFeatures?: string[];
}) {
const onboardingData = prepareOnboardingOnyxData(
introSelected,
Expand All @@ -4246,6 +4248,7 @@ function completeOnboarding({
userReportedIntegration,
wasInvited,
companySize,
selectedInterestedFeatures,
);
if (!onboardingData) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {shouldOnboardingRedirectToOldDot} from '@libs/OnboardingUtils';
import {isPaidGroupPolicy, isPolicyAdmin} from '@libs/PolicyUtils';
import {closeReactNativeApp} from '@userActions/HybridApp';
import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
import CONST, {FEATURE_IDS} from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import type {BaseOnboardingInterestedFeaturesProps, Feature, SectionObject} from './types';
Expand Down Expand Up @@ -67,66 +67,66 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
const features: Feature[] = useMemo(() => {
return [
{
id: 'categories',
id: FEATURE_IDS.CATEGORIES,
title: translate('workspace.moreFeatures.categories.title'),
icon: Illustrations.FolderOpen,
enabledByDefault: true,
apiEndpoint: WRITE_COMMANDS.ENABLE_POLICY_CATEGORIES,
},
{
id: 'accounting',
id: FEATURE_IDS.ACCOUNTING,
title: translate('workspace.moreFeatures.connections.title'),
icon: Illustrations.Accounting,
enabledByDefault: !!userReportedIntegration,
apiEndpoint: WRITE_COMMANDS.ENABLE_POLICY_CONNECTIONS,
},
{
id: 'company-cards',
id: FEATURE_IDS.COMPANY_CARDS,
title: translate('workspace.moreFeatures.companyCards.title'),
icon: Illustrations.CompanyCard,
enabledByDefault: true,
apiEndpoint: WRITE_COMMANDS.ENABLE_POLICY_COMPANY_CARDS,
},
{
id: 'workflows',
id: FEATURE_IDS.WORKFLOWS,
title: translate('workspace.moreFeatures.workflows.title'),
icon: Illustrations.Workflows,
enabledByDefault: true,
apiEndpoint: WRITE_COMMANDS.ENABLE_POLICY_WORKFLOWS,
},
{
id: 'invoices',
id: FEATURE_IDS.INVOICES,
title: translate('workspace.moreFeatures.invoices.title'),
icon: Illustrations.InvoiceBlue,
apiEndpoint: WRITE_COMMANDS.ENABLE_POLICY_INVOICING,
},
{
id: 'rules',
id: FEATURE_IDS.RULES,
title: translate('workspace.moreFeatures.rules.title'),
icon: Illustrations.Rules,
apiEndpoint: WRITE_COMMANDS.SET_POLICY_RULES_ENABLED,
requiresUpdate: true,
},
{
id: 'distance-rates',
id: FEATURE_IDS.DISTANCE_RATES,
title: translate('workspace.moreFeatures.distanceRates.title'),
icon: Illustrations.Car,
apiEndpoint: WRITE_COMMANDS.ENABLE_POLICY_DISTANCE_RATES,
},
{
id: 'expensify-card',
id: FEATURE_IDS.EXPENSIFY_CARD,
title: translate('workspace.moreFeatures.expensifyCard.title'),
icon: Illustrations.HandCard,
apiEndpoint: WRITE_COMMANDS.ENABLE_POLICY_EXPENSIFY_CARDS,
},
{
id: 'tags',
id: FEATURE_IDS.TAGS,
title: translate('workspace.moreFeatures.tags.title'),
icon: Illustrations.Tag,
apiEndpoint: WRITE_COMMANDS.ENABLE_POLICY_TAGS,
},
{
id: 'per-diem',
id: FEATURE_IDS.PER_DIEM,
title: translate('workspace.moreFeatures.perDiem.title'),
icon: Illustrations.PerDiem,
apiEndpoint: WRITE_COMMANDS.TOGGLE_POLICY_PER_DIEM,
Expand Down Expand Up @@ -209,6 +209,7 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
userReportedIntegration: newUserReportedIntegration,
firstName: currentUserPersonalDetails?.firstName,
lastName: currentUserPersonalDetails?.lastName,
selectedInterestedFeatures: featuresMap.filter((feature) => feature.enabled).map((feature) => feature.id),
});

if (shouldOnboardingRedirectToOldDot(onboardingCompanySize, newUserReportedIntegration)) {
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,25 @@ describe('ReportUtils', () => {
}),
);
});

it('should not create tasks if the task feature is not in the selected interested features', () => {
const result = prepareOnboardingOnyxData(
undefined,
CONST.ONBOARDING_CHOICES.MANAGE_TEAM,
{
message: 'This is a test',
tasks: [{type: CONST.ONBOARDING_TASK_TYPE.CONNECT_CORPORATE_CARD, title: () => '', description: () => '', autoCompleted: false, mediaAttributes: {}}],
},
'1',
undefined,
undefined,
undefined,
undefined,
['categories', 'accounting', 'tags'],
);

expect(result?.guidedSetupData.filter((data) => data.type === 'task')).toHaveLength(0);
});
});

describe('getIconsForParticipants', () => {
Expand Down