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
7 changes: 4 additions & 3 deletions src/DeepLinkHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) {
const [, sessionMetadata] = useOnyx(ONYXKEYS.SESSION);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const isAuthenticated = useIsAuthenticated();

useEffect(() => {
Expand All @@ -47,7 +48,7 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) {
if (introSelected === undefined) {
Log.info('[Deep link] introSelected is undefined when processing initial URL', false, {url});
}
openReportFromDeepLink(url, allReports, isAuthenticated, conciergeReportID, introSelected);
openReportFromDeepLink(url, allReports, isAuthenticated, conciergeReportID, introSelected, betas);
} else {
Report.doneCheckingPublicRoom();
}
Expand All @@ -64,14 +65,14 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) {
Log.info('[Deep link] introSelected is undefined when processing URL change', false, {url: state.url});
}
const isCurrentlyAuthenticated = hasAuthToken();
openReportFromDeepLink(state.url, allReports, isCurrentlyAuthenticated, conciergeReportID, introSelected);
openReportFromDeepLink(state.url, allReports, isCurrentlyAuthenticated, conciergeReportID, introSelected, betas);
});

return () => {
linkingChangeListener.current?.remove();
};
// eslint-disable-next-line react-hooks/exhaustive-deps -- we only want this effect to re-run when conciergeReportID changes
}, [sessionMetadata?.status, conciergeReportID, introSelected]);
}, [sessionMetadata?.status, conciergeReportID, introSelected, betas]);

return null;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/SettlementButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ function SettlementButton({
activePolicyID,
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
betas,
isSelfTourViewed,
}).policyID;
};
Expand Down
10 changes: 10 additions & 0 deletions src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,8 @@ type CreateWorkspaceWithPolicyDraftParams = {
currentUserEmailParam: string;
shouldCreateControlPolicy?: boolean;
type?: PolicyType;
// TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417)
betas?: OnyxEntry<OnyxTypes.Beta[]>;
};

/**
Expand All @@ -591,6 +593,7 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt(params: CreateWorkspaceWi
shouldCreateControlPolicy,
type,
isSelfTourViewed,
betas,
} = params;

const policyIDWithDefault = policyID || generatePolicyID();
Expand All @@ -617,6 +620,7 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt(params: CreateWorkspaceWi
shouldCreateControlPolicy,
type,
isSelfTourViewed,
betas,
});
Navigation.navigate(routeToNavigate, {forceReplace: !transitionFromOldDot});
});
Expand All @@ -637,6 +641,7 @@ function createWorkspaceWithPolicyDraft(params: CreateWorkspaceWithPolicyDraftPa
currentUserEmailParam,
shouldCreateControlPolicy,
isSelfTourViewed,
betas,
} = params;

createDraftInitialWorkspace(introSelected, policyOwnerEmail, policyName, policyID, makeMeAdmin, currency, file);
Expand All @@ -655,6 +660,7 @@ function createWorkspaceWithPolicyDraft(params: CreateWorkspaceWithPolicyDraftPa
allReportsParam: allReports,
shouldCreateControlPolicy,
isSelfTourViewed,
betas,
});
}

Expand All @@ -674,6 +680,8 @@ type SavePolicyDraftByNewWorkspaceParams = {
allReportsParam: OnyxCollection<OnyxTypes.Report>;
shouldCreateControlPolicy?: boolean;
type?: PolicyType;
// TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417)
betas?: OnyxEntry<OnyxTypes.Beta[]>;
};

/**
Expand All @@ -695,6 +703,7 @@ function savePolicyDraftByNewWorkspace({
shouldCreateControlPolicy,
type,
isSelfTourViewed,
betas,
}: SavePolicyDraftByNewWorkspaceParams) {
createWorkspace({
policyOwnerEmail,
Expand All @@ -713,6 +722,7 @@ function savePolicyDraftByNewWorkspace({
shouldCreateControlPolicy,
type,
isSelfTourViewed,
betas,
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@
};

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

Check warning on line 775 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 @@ -872,7 +872,7 @@
};

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
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,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -886,7 +886,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
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.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -895,7 +895,7 @@
});

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

Check warning on line 898 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 @@ -909,7 +909,7 @@
});

let allPolicyTags: OnyxCollection<OnyxTypes.PolicyTagLists> = {};
Onyx.connect({

Check warning on line 912 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_TAGS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -922,7 +922,7 @@
});

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

Check warning on line 925 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 @@ -931,7 +931,7 @@
});

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

Check warning on line 934 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 @@ -941,7 +941,7 @@

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

Check warning on line 944 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 @@ -950,7 +950,7 @@
});

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

Check warning on line 953 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 @@ -3832,6 +3832,7 @@
currentUserEmailParam,
introSelected,
activePolicyID,
betas,
isSelfTourViewed,
});
createdWorkspaceParams = workspaceData.params;
Expand Down Expand Up @@ -9330,6 +9331,7 @@
introSelected,
activePolicyID: activePolicy?.id,
companySize: introSelected?.companySize as OnboardingCompanySize,
betas,
isSelfTourViewed,
});
const {adminsChatReportID, adminsCreatedReportActionID, expenseChatReportID, expenseCreatedReportActionID, customUnitRateID, customUnitID, ownerEmail, policyName} = params;
Expand Down
13 changes: 10 additions & 3 deletions src/libs/actions/Link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type {IntroSelected, Report} from '@src/types/onyx';
import type {Beta, IntroSelected, Report} from '@src/types/onyx';
import {doneCheckingPublicRoom, navigateToConciergeChat, openReport} from './Report';
import {canAnonymousUserAccessRoute, isAnonymousUser, signOutAndRedirectToSignIn, waitForUserSignIn} from './Session';
import {setOnboardingErrorMessage} from './Welcome';
Expand Down Expand Up @@ -232,7 +232,14 @@ function openLink(href: string, environmentURL: string, isAttachment = false) {
openExternalLink(href);
}

function openReportFromDeepLink(url: string, reports: OnyxCollection<Report>, isAuthenticated: boolean, conciergeReportID: string | undefined, introSelected: OnyxEntry<IntroSelected>) {
function openReportFromDeepLink(
url: string,
reports: OnyxCollection<Report>,
isAuthenticated: boolean,
conciergeReportID: string | undefined,
introSelected: OnyxEntry<IntroSelected>,
betas: OnyxEntry<Beta[]>,
) {
const reportID = getReportIDFromLink(url);

if (reportID && !isAuthenticated) {
Expand All @@ -244,7 +251,7 @@ function openReportFromDeepLink(url: string, reports: OnyxCollection<Report>, is
});

// Call the OpenReport command to check in the server if it's a public room. If so, we'll open it as an anonymous user
openReport({reportID, introSelected, parentReportActionID: '0', isFromDeepLink: true});
openReport({reportID, introSelected, parentReportActionID: '0', isFromDeepLink: true, betas});

// Show the sign-in page if the app is offline
if (networkStatus === CONST.NETWORK.NETWORK_STATUS.OFFLINE) {
Expand Down
4 changes: 4 additions & 0 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ type BuildPolicyDataOptions = {
type?: typeof CONST.POLICY.TYPE.TEAM | typeof CONST.POLICY.TYPE.CORPORATE;
// TODO: Make it required once we complete refactoring the buildPolicyData function to use isSelfTourViewed. Refactor issue: https://github.com/Expensify/App/issues/66424
isSelfTourViewed?: boolean;
// TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417)
betas?: OnyxEntry<Beta[]>;
};

// TODO: Remove this type once we complete refactoring the buildPolicyData function to use isSelfTourViewed. Refactor issue: https://github.com/Expensify/App/issues/66424
Expand Down Expand Up @@ -2388,6 +2390,7 @@ function buildPolicyData(options: BuildPolicyDataOptions): OnyxData<BuildPolicyD
shouldCreateControlPolicy = false,
type,
isSelfTourViewed,
betas,
} = options;
const workspaceName = policyName || generateDefaultWorkspaceName(policyOwnerEmail);

Expand Down Expand Up @@ -2853,6 +2856,7 @@ function buildPolicyData(options: BuildPolicyDataOptions): OnyxData<BuildPolicyD
onboardingPurposeSelected,
companySize: companySize ?? (introSelected?.companySize as OnboardingCompanySize),
isSelfTourViewed,
betas,
});
if (!onboardingData) {
return {successData, optimisticData, failureData, params};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
shouldAddGuideWelcomeMessage: false,
betas,
isSelfTourViewed,
})
: {adminsChatReportID: onboardingAdminsChatReportID, policyID: onboardingPolicyID};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function BaseOnboardingWorkspaceConfirmation({shouldUseNativeStyles}: BaseOnboar
const styles = useThemeStyles();
const {translate} = useLocalize();
const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID);
const [onboardingAdminsChatReportID] = useOnyx(ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID);
Expand Down Expand Up @@ -84,6 +85,7 @@ function BaseOnboardingWorkspaceConfirmation({shouldUseNativeStyles}: BaseOnboar
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
shouldAddGuideWelcomeMessage: false,
onboardingPurposeSelected,
betas,
isSelfTourViewed,
})
: {adminsChatReportID: onboardingAdminsChatReportID, policyID: onboardingPolicyID};
Expand All @@ -104,6 +106,7 @@ function BaseOnboardingWorkspaceConfirmation({shouldUseNativeStyles}: BaseOnboar
currentUserPersonalDetails.accountID,
currentUserPersonalDetails.email,
introSelected,
betas,
isSelfTourViewed,
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function BaseOnboardingWorkspaceOptional({shouldUseNativeStyles}: BaseOnboarding
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
shouldAddGuideWelcomeMessage: false,
onboardingPurposeSelected,
betas,
isSelfTourViewed,
})
: {adminsChatReportID: onboardingAdminsChatReportID, policyID: onboardingPolicyID};
Expand All @@ -189,6 +190,7 @@ function BaseOnboardingWorkspaceOptional({shouldUseNativeStyles}: BaseOnboarding
currentUserPersonalDetails.email,
introSelected,
activePolicyID,
betas,
isSelfTourViewed,
completeOnboarding,
]);
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Travel/WorkspaceConfirmationForTravelPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type WorkspaceConfirmationForTravelPageProps = StackScreenProps<TravelNavigatorP

function WorkspaceConfirmationForTravelPage({route}: WorkspaceConfirmationForTravelPageProps) {
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

Expand All @@ -38,6 +39,7 @@ function WorkspaceConfirmationForTravelPage({route}: WorkspaceConfirmationForTra
activePolicyID,
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
betas,
isSelfTourViewed,
});
goBack();
Expand Down
3 changes: 3 additions & 0 deletions src/pages/iou/request/step/IOURequestStepUpgrade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function IOURequestStepUpgrade({
const isWeb = platform === CONST.PLATFORM.WEB;
const {isRestrictedPolicyCreation} = usePreferredPolicy();
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

Expand Down Expand Up @@ -164,6 +165,7 @@ function IOURequestStepUpgrade({
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
onboardingPurposeSelected,
betas,
isSelfTourViewed,
});
setIsUpgraded(true);
Expand All @@ -190,6 +192,7 @@ function IOURequestStepUpgrade({
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
onboardingPurposeSelected,
betas,
isSelfTourViewed,
});
policyDataRef.current = policyData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function PersonalCardUpgradePage() {
const {isOffline} = useNetwork();
const [isUpgraded, setIsUpgraded] = useState(false);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [lastPaymentMethod] = useOnyx(ONYXKEYS.NVP_LAST_PAYMENT_METHOD);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
Expand All @@ -44,6 +45,7 @@ function PersonalCardUpgradePage() {
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
shouldCreateControlPolicy: false,
isSelfTourViewed,
betas,
});
setIsUpgraded(true);
};
Expand Down
2 changes: 2 additions & 0 deletions src/pages/workspace/WorkspaceConfirmationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function WorkspaceConfirmationPage() {
const [lastPaymentMethod] = useOnyx(ONYXKEYS.NVP_LAST_PAYMENT_METHOD);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

const currentUserPersonalDetails = useCurrentUserPersonalDetails();
Expand All @@ -48,6 +49,7 @@ function WorkspaceConfirmationPage() {
shouldCreateControlPolicy: isSubscriptionTypeOfInvoicing(privateSubscription?.type),
type: params.planType,
isSelfTourViewed,
betas,
});
};
const currentUrl = getCurrentUrl();
Expand Down
31 changes: 31 additions & 0 deletions tests/actions/PolicyTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,37 @@ describe('actions/Policy', () => {
expect(policy?.approvalMode).toBe(CONST.POLICY.APPROVAL_MODE.BASIC);
});

it('creates a new workspace when betas are explicitly passed', async () => {
const policyID = Policy.generatePolicyID();
Policy.createWorkspace({
policyOwnerEmail: ESH_EMAIL,
makeMeAdmin: true,
policyName: WORKSPACE_NAME,
policyID,
engagementChoice: CONST.ONBOARDING_CHOICES.MANAGE_TEAM,
introSelected: {choice: CONST.ONBOARDING_CHOICES.MANAGE_TEAM},
currentUserAccountIDParam: ESH_ACCOUNT_ID,
currentUserEmailParam: ESH_EMAIL,
isSelfTourViewed: false,
betas: [CONST.BETAS.SUGGESTED_FOLLOWUPS],
});
await waitForBatchedUpdates();

const policy: OnyxEntry<PolicyType> | OnyxCollection<PolicyType> = await new Promise((resolve) => {
const connection = Onyx.connect({
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
callback: (workspace) => {
Onyx.disconnect(connection);
resolve(workspace);
},
});
});

expect(policy?.id).toBe(policyID);
expect(policy?.name).toBe(WORKSPACE_NAME);
expect(policy?.approvalMode).toBe(CONST.POLICY.APPROVAL_MODE.BASIC);
});

it('creates a new workspace with OPTIONAL approval mode if the introSelected is TRACK_WORKSPACE', async () => {
const policyID = Policy.generatePolicyID();
// When a new workspace is created with introSelected set to TRACK_WORKSPACE
Expand Down
Loading