diff --git a/src/components/TestDrive/TestDriveDemo.tsx b/src/components/TestDrive/TestDriveDemo.tsx index 4f5c84ac259b..41bf6c0ce630 100644 --- a/src/components/TestDrive/TestDriveDemo.tsx +++ b/src/components/TestDrive/TestDriveDemo.tsx @@ -24,14 +24,12 @@ function TestDriveDemo() { const [onboarding] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {canBeMissing: false}); const [onboardingReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${onboarding?.chatReportID}`, {canBeMissing: true}); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); - const viewTourReportID = introSelected?.viewTour; - const [viewTourReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourReportID}`, {canBeMissing: true}); const {testDrive} = useOnboardingMessages(); useEffect(() => { InteractionManager.runAfterInteractions(() => { setIsVisible(true); - completeTestDriveTask(viewTourReport, viewTourReportID); + completeTestDriveTask(); }); // This should fire only during mount. diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index f2809d2997fd..936e89ca2a23 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1324,9 +1324,9 @@ function getFinishOnboardingTaskOnyxData(taskName: IntroSelectedTask): OnyxData return {}; } -function completeTestDriveTask(viewTourReport: OnyxEntry, viewTourReportID: string | undefined, shouldUpdateSelfTourViewedOnlyLocally = false) { +function completeTestDriveTask(shouldUpdateSelfTourViewedOnlyLocally = false) { setSelfTourViewed(shouldUpdateSelfTourViewedOnlyLocally); - completeTask(viewTourReport, viewTourReportID); + getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); } export { diff --git a/src/pages/Search/EmptySearchView.tsx b/src/pages/Search/EmptySearchView.tsx index e251fe5d794c..8a11eb666f6c 100644 --- a/src/pages/Search/EmptySearchView.tsx +++ b/src/pages/Search/EmptySearchView.tsx @@ -163,8 +163,6 @@ function EmptySearchView({hash, type, groupBy, hasResults}: EmptySearchViewProps selector: hasSeenTourSelector, canBeMissing: true, }); - const viewTourReportID = introSelected?.viewTour; - const [viewTourReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourReportID}`, {canBeMissing: true}); // Default 'Folder' lottie animation, along with its background styles const defaultViewItemHeader = useMemo( @@ -204,7 +202,7 @@ function EmptySearchView({hash, type, groupBy, hasResults}: EmptySearchViewProps introSelected?.choice === CONST.ONBOARDING_CHOICES.TRACK_WORKSPACE || (introSelected?.choice === CONST.ONBOARDING_CHOICES.SUBMIT && introSelected.inviteType === CONST.ONBOARDING_INVITE_TYPES.WORKSPACE) ) { - completeTestDriveTask(viewTourReport, viewTourReportID); + completeTestDriveTask(); Navigation.navigate(ROUTES.TEST_DRIVE_DEMO_ROOT); } else { Navigation.navigate(ROUTES.TEST_DRIVE_MODAL_ROOT.route); @@ -382,8 +380,6 @@ function EmptySearchView({hash, type, groupBy, hasResults}: EmptySearchViewProps currentUserPersonalDetails, tripViewChildren, shouldRedirectToExpensifyClassic, - viewTourReport, - viewTourReportID, transactions, ]); diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index 6e85f0f3315b..4a63e611ab34 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -135,8 +135,6 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT selector: hasSeenTourSelector, canBeMissing: true, }); - const viewTourReportID = introSelected?.viewTour; - const [viewTourReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourReportID}`, {canBeMissing: true}); const groupPoliciesWithChatEnabled = getGroupPaidPoliciesWithExpenseChatEnabled(); @@ -537,7 +535,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT introSelected?.choice === CONST.ONBOARDING_CHOICES.TRACK_WORKSPACE || (introSelected?.choice === CONST.ONBOARDING_CHOICES.SUBMIT && introSelected.inviteType === CONST.ONBOARDING_INVITE_TYPES.WORKSPACE) ) { - completeTestDriveTask(viewTourReport, viewTourReportID, isAnonymousUser()); + completeTestDriveTask(isAnonymousUser()); Navigation.navigate(ROUTES.TEST_DRIVE_DEMO_ROOT); } else { Navigation.navigate(ROUTES.TEST_DRIVE_MODAL_ROOT.route); diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 8aa53b902226..28c3e816dad8 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -189,10 +189,6 @@ function IOURequestStepConfirmation({ const [isConfirmed, setIsConfirmed] = useState(false); const [isConfirming, setIsConfirming] = useState(false); - const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); - const viewTourReportID = introSelected?.viewTour; - const [viewTourReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourReportID}`, {canBeMissing: true}); - const headerTitle = useMemo(() => { if (isCategorizingTrackExpense) { return translate('iou.categorize'); @@ -453,7 +449,7 @@ function IOURequestStepConfirmation({ const isTestDriveReceipt = receipt?.isTestDriveReceipt ?? false; if (isTestDriveReceipt) { - completeTestDriveTask(viewTourReport, viewTourReportID); + completeTestDriveTask(); } requestMoneyIOUActions({ @@ -515,8 +511,6 @@ function IOURequestStepConfirmation({ transactionTaxAmount, customUnitRateID, backToReport, - viewTourReport, - viewTourReportID, ], ); diff --git a/tests/actions/TaskTest.ts b/tests/actions/TaskTest.ts index d1cd2c0b64d9..ef0dedafcadd 100644 --- a/tests/actions/TaskTest.ts +++ b/tests/actions/TaskTest.ts @@ -4,8 +4,6 @@ import useParentReport from '@hooks/useParentReport'; import useReportIsArchived from '@hooks/useReportIsArchived'; import {canActionTask, canModifyTask, completeTestDriveTask, getFinishOnboardingTaskOnyxData} from '@libs/actions/Task'; // eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking -import * as API from '@libs/API'; -import {WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; import {translateLocal} from '@libs/Localize'; import Parser from '@libs/Parser'; @@ -223,11 +221,8 @@ describe('actions/Task', () => { }); it('Completes test drive task', () => { - const writeSpy = jest.spyOn(API, 'write'); - - completeTestDriveTask(testDriveTaskReport, testDriveTaskReport.reportID); - - expect(writeSpy).toHaveBeenCalledWith(WRITE_COMMANDS.COMPLETE_TASK, expect.anything(), expect.anything()); + completeTestDriveTask(); + expect(Object.values(getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR)).length).toBe(0); }); });