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
14 changes: 13 additions & 1 deletion src/components/TestDrive/TestDriveDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import useThemeStyles from '@hooks/useThemeStyles';
import {completeTestDriveTask} from '@libs/actions/Task';
import Navigation from '@libs/Navigation/Navigation';
import {hasSeenTourSelector} from '@libs/onboardingSelectors';
import {isPaidGroupPolicy, isPolicyAdmin} from '@libs/PolicyUtils';
import {isAdminRoom} from '@libs/ReportUtils';
import {getTestDriveURL} from '@libs/TourUtils';
Expand Down Expand Up @@ -39,11 +40,22 @@
selector: (policies) => Object.values(policies ?? {}).some((policy) => isPaidGroupPolicy(policy) && isPolicyAdmin(policy, currentUserPersonalDetails.login)),
});

const [hasSeenTour = false] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
selector: hasSeenTourSelector,
canBeMissing: true,
});

useEffect(() => {
if (hasSeenTour) {
return;
}
completeTestDriveTask(viewTourTaskReport, viewTourTaskParentReport, isViewTourTaskParentReportArchived, currentUserPersonalDetails.accountID);
}, [hasSeenTour]);

Check warning on line 53 in src/components/TestDrive/TestDriveDemo.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useEffect has missing dependencies: 'currentUserPersonalDetails.accountID', 'isViewTourTaskParentReportArchived', 'viewTourTaskParentReport', and 'viewTourTaskReport'. Either include them or remove the dependency array

Check warning on line 53 in src/components/TestDrive/TestDriveDemo.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useEffect has missing dependencies: 'currentUserPersonalDetails.accountID', 'isViewTourTaskParentReportArchived', 'viewTourTaskParentReport', and 'viewTourTaskReport'. Either include them or remove the dependency array

useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => {
setIsVisible(true);
completeTestDriveTask(viewTourTaskReport, viewTourTaskParentReport, isViewTourTaskParentReportArchived, currentUserPersonalDetails.accountID);
});

// This should fire only during mount.
Expand Down
15 changes: 1 addition & 14 deletions src/libs/actions/Tour.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import {InteractionManager} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import type * as OnyxTypes from '@src/types/onyx';
import type {IntroSelected} from './Report';
import {completeTestDriveTask} from './Task';

function startTestDrive(
introSelected: IntroSelected | undefined,
shouldUpdateSelfTourViewedOnlyLocally: boolean,
hasUserBeenAddedToNudgeMigration: boolean,
isUserPaidPolicyMember: boolean,
viewTourTaskReport: OnyxEntry<OnyxTypes.Report>,
viewTourTaskParentReport: OnyxEntry<OnyxTypes.Report>,
isViewTourTaskParentReportArchived: boolean,
currentUserAccountID: number,
) {
function startTestDrive(introSelected: IntroSelected | undefined, hasUserBeenAddedToNudgeMigration: boolean, isUserPaidPolicyMember: boolean) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => {
if (
Expand All @@ -27,7 +15,6 @@ function startTestDrive(
introSelected?.choice === CONST.ONBOARDING_CHOICES.TRACK_WORKSPACE ||
(introSelected?.choice === CONST.ONBOARDING_CHOICES.SUBMIT && introSelected.inviteType === CONST.ONBOARDING_INVITE_TYPES.WORKSPACE)
) {
completeTestDriveTask(viewTourTaskReport, viewTourTaskParentReport, isViewTourTaskParentReportArchived, currentUserAccountID, shouldUpdateSelfTourViewedOnlyLocally);
Navigation.navigate(ROUTES.TEST_DRIVE_DEMO_ROOT);
} else {
Navigation.navigate(ROUTES.TEST_DRIVE_MODAL_ROOT.route);
Expand Down
11 changes: 1 addition & 10 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,7 @@
}

const startTestDriveAction = () => {
startTestDrive(
introSelected,
false,
tryNewDot?.hasBeenAddedToNudgeMigration ?? false,
isUserPaidPolicyMember,
viewTourTaskReport,
viewTourTaskParentReport,
isViewTourTaskParentReportArchived,
currentUserPersonalDetails.accountID,
);
startTestDrive(introSelected, tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember);
};

// If we didn't match a specific search hash, show a specific message based on the type of the data
Expand Down Expand Up @@ -456,7 +447,7 @@
subtitle: translate('search.searchResults.emptyResults.subtitle'),
};
}
}, [

Check warning on line 450 in src/pages/Search/EmptySearchView.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useMemo has unnecessary dependencies: 'isViewTourTaskParentReportArchived', 'viewTourTaskParentReport', and 'viewTourTaskReport'. Either exclude them or remove the dependency array
type,
typeMenuItems,
similarSearchHash,
Expand Down
22 changes: 1 addition & 21 deletions src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import PopoverMenu from '@components/PopoverMenu';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnboardingTaskInformation from '@hooks/useOnboardingTaskInformation';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import usePreferredPolicy from '@hooks/usePreferredPolicy';
Expand All @@ -30,7 +29,6 @@ import {startDistanceRequest, startMoneyRequest} from '@libs/actions/IOU';
import {openOldDotLink} from '@libs/actions/Link';
import {navigateToQuickAction} from '@libs/actions/QuickActionNavigation';
import {createNewReport, startNewChat} from '@libs/actions/Report';
import {isAnonymousUser} from '@libs/actions/Session';
import {startTestDrive} from '@libs/actions/Tour';
import getIconForAction from '@libs/getIconForAction';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
Expand Down Expand Up @@ -163,12 +161,6 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref
});
const reportID = useMemo(() => generateReportID(), []);

const {
taskReport: viewTourTaskReport,
taskParentReport: viewTourTaskParentReport,
isOnboardingTaskParentReportArchived: isViewTourTaskParentReportArchived,
} = useOnboardingTaskInformation(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR);

const isReportInSearch = isOnSearchMoneyRequestReportPage();
const groupPoliciesWithChatEnabled = getGroupPaidPoliciesWithExpenseChatEnabled();

Expand Down Expand Up @@ -564,19 +556,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref
iconStyles: styles.popoverIconCircle,
iconFill: theme.icon,
text: translate('testDrive.quickAction.takeATwoMinuteTestDrive'),
onSelected: () =>
interceptAnonymousUser(() =>
startTestDrive(
introSelected,
isAnonymousUser(),
tryNewDot?.hasBeenAddedToNudgeMigration ?? false,
isUserPaidPolicyMember,
viewTourTaskReport,
viewTourTaskParentReport,
isViewTourTaskParentReportArchived,
currentUserPersonalDetails.accountID,
),
),
onSelected: () => interceptAnonymousUser(() => startTestDrive(introSelected, tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember)),
},
]
: []),
Expand Down
21 changes: 6 additions & 15 deletions tests/actions/TourTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ describe('actions/Tour', () => {
describe('startTestDrive', () => {
describe('migrated users', () => {
it('should show the Test Drive demo if user has been nudged to migrate', async () => {
startTestDrive(undefined, false, true, false, undefined, undefined, false, 2);
startTestDrive(undefined, true, false);
await waitForBatchedUpdates();

expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT);
});

it("should show the Test Drive demo if user doesn't have the nudge flag but is member of a paid policy", async () => {
startTestDrive(undefined, false, false, true, undefined, undefined, false, 2);
startTestDrive(undefined, false, true);
await waitForBatchedUpdates();

expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT);
Expand Down Expand Up @@ -86,14 +86,14 @@ describe('actions/Tour', () => {
it.each(onboardingChoices.filter((choice) => onboardingDemoChoices.includes(choice)))('should show the Test Drive demo if user has "%s" onboarding choice', async (choice) => {
await setTestDriveTaskData();

startTestDrive({choice}, false, false, false, testDriveTaskReport, conciergeChatReport, false, accountID);
startTestDrive({choice}, false, false);
await waitForBatchedUpdates();

expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT);
});

it.each(onboardingChoices.filter((choice) => !onboardingDemoChoices.includes(choice)))('should show the Test Drive modal if user has "%s" onboarding choice', async (choice) => {
startTestDrive({choice}, false, false, false, undefined, undefined, false, accountID);
startTestDrive({choice}, false, false);
await waitForBatchedUpdates();

expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_MODAL_ROOT.route);
Expand All @@ -102,23 +102,14 @@ describe('actions/Tour', () => {
it('should show the Test Drive demo if user is an invited employee', async () => {
await setTestDriveTaskData();

startTestDrive(
{choice: CONST.ONBOARDING_CHOICES.SUBMIT, inviteType: CONST.ONBOARDING_INVITE_TYPES.WORKSPACE},
false,
false,
false,
testDriveTaskReport,
conciergeChatReport,
false,
accountID,
);
startTestDrive({choice: CONST.ONBOARDING_CHOICES.SUBMIT, inviteType: CONST.ONBOARDING_INVITE_TYPES.WORKSPACE}, false, false);
await waitForBatchedUpdates();

expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT);
});

it('should show the Test Drive demo if user is member of a paid policy', async () => {
startTestDrive({choice: CONST.ONBOARDING_CHOICES.LOOKING_AROUND}, false, false, true, testDriveTaskReport, conciergeChatReport, false, accountID);
startTestDrive({choice: CONST.ONBOARDING_CHOICES.LOOKING_AROUND}, false, true);
await waitForBatchedUpdates();

expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT);
Expand Down
Loading