Skip to content
Open
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
12 changes: 2 additions & 10 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1210,14 +1210,6 @@ Onyx.connectWithoutView({
callback: (value) => (newGroupChatDraft = value),
});

let onboardingCompanySize: OnyxEntry<OnboardingCompanySize>;
Onyx.connectWithoutView({
key: ONYXKEYS.ONBOARDING_COMPANY_SIZE,
callback: (value) => {
onboardingCompanySize = value;
},
});

let cachedSelfDMReportID: OnyxEntry<string>;
Onyx.connectWithoutView({
key: ONYXKEYS.SELF_DM_REPORT_ID,
Expand Down Expand Up @@ -11289,7 +11281,7 @@ type PrepareOnboardingOnyxDataParams = {
onboardingPolicyID?: string;
userReportedIntegration?: OnboardingAccounting;
wasInvited?: boolean;
companySize?: OnboardingCompanySize;
companySize: OnboardingCompanySize | undefined;
selectedInterestedFeatures?: string[];
isInvitedAccountant?: boolean;
onboardingPurposeSelected?: OnboardingPurpose;
Expand Down Expand Up @@ -11370,7 +11362,7 @@ function prepareOnboardingOnyxData({

const onboardingTaskParams: OnboardingTaskLinks = {
integrationName,
onboardingCompanySize: companySize ?? onboardingCompanySize,
onboardingCompanySize: companySize,
workspaceSettingsLink: `${environmentURL}/${ROUTES.WORKSPACE_OVERVIEW.getRoute(onboardingPolicyID ?? firstAdminPolicy?.id)}`,
workspaceCategoriesLink: `${environmentURL}/${ROUTES.WORKSPACE_CATEGORIES.getRoute(onboardingPolicyID)}`,
workspaceTagsLink: `${environmentURL}/${ROUTES.WORKSPACE_TAGS.getRoute(onboardingPolicyID)}`,
Expand Down
4 changes: 4 additions & 0 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
import {sanitizeRecentWaypoints} from '@userActions/Transaction';
import {removeDraftSplitTransaction, removeDraftTransaction, removeDraftTransactions} from '@userActions/TransactionEdit';
import {getOnboardingMessages} from '@userActions/Welcome/OnboardingFlow';
import type {OnboardingCompanySize} from '@userActions/Welcome/OnboardingFlow';
import type {IOUAction, IOUActionParams, IOUType} from '@src/CONST';
import CONST from '@src/CONST';
import NAVIGATORS from '@src/NAVIGATORS';
Expand Down Expand Up @@ -752,7 +753,7 @@
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 756 in src/libs/actions/IOU/index.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.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -848,7 +849,7 @@
};

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 852 in src/libs/actions/IOU/index.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.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -862,7 +863,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 866 in src/libs/actions/IOU/index.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.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -871,7 +872,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
Onyx.connect({

Check warning on line 875 in src/libs/actions/IOU/index.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.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -885,7 +886,7 @@
});

let allNextSteps: NonNullable<OnyxCollection<OnyxTypes.ReportNextStepDeprecated>> = {};
Onyx.connect({

Check warning on line 889 in src/libs/actions/IOU/index.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.NEXT_STEP,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -897,14 +898,14 @@
// `allRecentlyUsedTags` was moved here temporarily from `src/libs/actions/Policy/Tag.ts` during the `Deprecate Onyx.connect` refactor.
// All uses of this variable should be replaced with `useOnyx`.
let allRecentlyUsedTags: OnyxCollection<RecentlyUsedTags> = {};
Onyx.connect({

Check warning on line 901 in src/libs/actions/IOU/index.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_RECENTLY_USED_TAGS,
waitForCollectionCallback: true,
callback: (val) => (allRecentlyUsedTags = val),
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 908 in src/libs/actions/IOU/index.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.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -913,7 +914,7 @@
});

let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 917 in src/libs/actions/IOU/index.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.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -923,7 +924,7 @@

let userAccountID = -1;
let currentUserEmail = '';
Onyx.connect({

Check warning on line 927 in src/libs/actions/IOU/index.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) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -932,7 +933,7 @@
});

let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>;
Onyx.connect({

Check warning on line 936 in src/libs/actions/IOU/index.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.PERSONAL_DETAILS_LIST,
callback: (value) => {
deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined;
Expand Down Expand Up @@ -6522,6 +6523,7 @@
introSelected: {choice: CONST.ONBOARDING_CHOICES.TEST_DRIVE_RECEIVER},
engagementChoice: CONST.ONBOARDING_CHOICES.TEST_DRIVE_RECEIVER,
onboardingMessage: getOnboardingMessages().onboardingMessages[CONST.ONBOARDING_CHOICES.TEST_DRIVE_RECEIVER],
companySize: undefined,
})?.guidedSetupData
: undefined;

Expand Down Expand Up @@ -10055,6 +10057,7 @@
currentUserEmailParam,
introSelectedParam,
activePolicyIDParam: activePolicy?.id,
companySize: introSelectedParam?.companySize as OnboardingCompanySize,
});
const {adminsChatReportID, adminsCreatedReportActionID, expenseChatReportID, expenseCreatedReportActionID, customUnitRateID, customUnitID, ownerEmail, policyName} = params;

Expand Down Expand Up @@ -11668,6 +11671,7 @@
paymentSelected,
wasInvited: true,
shouldSkipTestDriveModal: true,
companySize: introSelected?.companySize as OnboardingCompanySize,
});
}
function payMoneyRequest(
Expand Down
2 changes: 2 additions & 0 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) {
.filter((p) => p && p.id !== activePolicyID && p.type !== CONST.POLICY.TYPE.PERSONAL && p.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE)
.sort((policyA, policyB) => localeCompare(policyB?.created ?? '', policyA?.created ?? ''))
.at(0);
// eslint-disable-next-line @typescript-eslint/no-deprecated
const newActivePolicyID = mostRecentlyCreatedGroupPolicy?.id ?? PolicyUtils.getPersonalPolicy()?.id;

// @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830
Expand Down Expand Up @@ -2506,6 +2507,7 @@ function buildPolicyData(options: BuildPolicyDataOptions) {
adminsChatReportID,
onboardingPolicyID: policyID,
onboardingPurposeSelected,
companySize: companySize ?? (introSelected?.companySize as OnboardingCompanySize),
});
if (!onboardingData) {
return {successData, optimisticData, failureData, params};
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ function openReport(
introSelected,
engagementChoice: choice,
onboardingMessage,
companySize: introSelected?.companySize as OnboardingCompanySize,
});

if (onboardingData) {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro
const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID, {canBeMissing: true});
const [onboardingAdminsChatReportID] = useOnyx(ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID, {canBeMissing: true});
const [personalDetailsForm] = useOnyx(ONYXKEYS.FORMS.ONBOARDING_PERSONAL_DETAILS_FORM, {canBeMissing: true});

const [onboardingCompanySize] = useOnyx(ONYXKEYS.ONBOARDING_COMPANY_SIZE, {canBeMissing: true});
const paddingHorizontal = onboardingIsMediumOrLargerScreenWidth ? styles.ph8 : styles.ph5;

const [customChoices = getEmptyArray<OnboardingPurpose>()] = useOnyx(ONYXKEYS.ONBOARDING_CUSTOM_CHOICES, {canBeMissing: true});
Expand Down Expand Up @@ -104,6 +104,7 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro
lastName: personalDetailsForm.lastName,
adminsChatReportID: onboardingAdminsChatReportID ?? undefined,
onboardingPolicyID,
companySize: onboardingCompanySize,
});

// eslint-disable-next-line @typescript-eslint/no-deprecated
Expand Down
5 changes: 3 additions & 2 deletions src/pages/OnboardingWorkspaces/BaseOnboardingWorkspaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function BaseOnboardingWorkspaces({route, shouldUseNativeStyles}: BaseOnboarding
const joinablePoliciesLength = Object.keys(joinablePolicies ?? {}).length;

const [onboardingPersonalDetails] = useOnyx(ONYXKEYS.FORMS.ONBOARDING_PERSONAL_DETAILS_FORM, {canBeMissing: true});

const [onboardingCompanySize] = useOnyx(ONYXKEYS.ONBOARDING_COMPANY_SIZE, {canBeMissing: true});
const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true});
const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true});

Expand All @@ -70,13 +70,14 @@ function BaseOnboardingWorkspaces({route, shouldUseNativeStyles}: BaseOnboarding
firstName: onboardingPersonalDetails?.firstName ?? '',
lastName: onboardingPersonalDetails?.lastName ?? '',
shouldSkipTestDriveModal: !!(policy.automaticJoiningEnabled ? policy.policyID : undefined),
companySize: onboardingCompanySize,
});
setOnboardingAdminsChatReportID();
setOnboardingPolicyID(policy.policyID);

navigateAfterOnboardingWithMicrotaskQueue(isSmallScreenWidth, isBetaEnabled(CONST.BETAS.DEFAULT_ROOMS), policy.automaticJoiningEnabled ? policy.policyID : undefined);
},
[onboardingMessages, onboardingPersonalDetails?.firstName, onboardingPersonalDetails?.lastName, isSmallScreenWidth, isBetaEnabled],
[onboardingMessages, onboardingPersonalDetails?.firstName, onboardingPersonalDetails?.lastName, isSmallScreenWidth, isBetaEnabled, onboardingCompanySize],
);

const policyIDItems = useMemo(() => {
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ describe('ReportUtils', () => {
],
},
adminsChatReportID: '1',
companySize: CONST.ONBOARDING_COMPANY_SIZE.MICRO,
});

expect(title).toHaveBeenCalledWith(
Expand Down Expand Up @@ -456,6 +457,7 @@ describe('ReportUtils', () => {
],
},
adminsChatReportID: '1',
companySize: CONST.ONBOARDING_COMPANY_SIZE.MICRO,
});

expect(description).toHaveBeenCalledWith(
Expand All @@ -476,6 +478,7 @@ describe('ReportUtils', () => {
},
adminsChatReportID: '1',
selectedInterestedFeatures: ['categories', 'accounting', 'tags'],
companySize: CONST.ONBOARDING_COMPANY_SIZE.MICRO,
});

expect(result?.guidedSetupData.filter((data) => data.type === 'task')).toHaveLength(0);
Expand All @@ -492,6 +495,7 @@ describe('ReportUtils', () => {
tasks: [],
},
adminsChatReportID: '1',
companySize: CONST.ONBOARDING_COMPANY_SIZE.MICRO,
});

const personalDetailsCall = mergeSpy.mock.calls.find((call) => call[0] === ONYXKEYS.PERSONAL_DETAILS_LIST);
Expand Down
Loading