From 44b00a1bde09fa38f12f2a8ebee189cdc4211a62 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 9 Sep 2025 01:30:30 +0530 Subject: [PATCH 01/15] Refactor ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS in src/libs/actions/Task.ts --- src/libs/actions/Task.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index f280b92548b8f..9da6671822253 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -89,7 +89,8 @@ Onyx.connect({ }); let allReportNameValuePair: OnyxCollection; -Onyx.connect({ +// allReportNameValuePair is used on getFinishOnboardingTaskOnyxData to generate Onyx optimistic data +Onyx.connectWithoutView({ key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, waitForCollectionCallback: true, callback: (value) => { From 1799d139ff674ef4f705d56833a74060d5f98194 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 15:34:00 +0530 Subject: [PATCH 02/15] Refactor completeTestDriveTask --- src/components/TestDrive/TestDriveDemo.tsx | 6 +++++- src/hooks/useViewTourTask.ts | 16 ++++++++++++++++ src/libs/actions/Task.ts | 10 ++++------ src/libs/actions/Tour.ts | 3 ++- src/pages/Search/EmptySearchView.tsx | 5 ++++- .../sidebar/FloatingActionButtonAndPopover.tsx | 7 ++++++- .../request/step/IOURequestStepConfirmation.tsx | 5 ++++- 7 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 src/hooks/useViewTourTask.ts diff --git a/src/components/TestDrive/TestDriveDemo.tsx b/src/components/TestDrive/TestDriveDemo.tsx index 988758ee372b5..b555a59c16e5c 100644 --- a/src/components/TestDrive/TestDriveDemo.tsx +++ b/src/components/TestDrive/TestDriveDemo.tsx @@ -9,6 +9,7 @@ import useOnboardingMessages from '@hooks/useOnboardingMessages'; import useOnyx from '@hooks/useOnyx'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; +import useViewTourTask from '@hooks/useViewTourTask'; import {completeTestDriveTask} from '@libs/actions/Task'; import Navigation from '@libs/Navigation/Navigation'; import {isPaidGroupPolicy, isPolicyAdmin} from '@libs/PolicyUtils'; @@ -26,6 +27,9 @@ 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 {isViewTourParentReportAcrhived} = useViewTourTask(); + const {testDrive} = useOnboardingMessages(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [isCurrentUserPolicyAdmin = false] = useOnyx(ONYXKEYS.COLLECTION.POLICY, { @@ -36,7 +40,7 @@ function TestDriveDemo() { useEffect(() => { InteractionManager.runAfterInteractions(() => { setIsVisible(true); - completeTestDriveTask(); + completeTestDriveTask(isViewTourParentReportAcrhived); }); // This should fire only during mount. diff --git a/src/hooks/useViewTourTask.ts b/src/hooks/useViewTourTask.ts new file mode 100644 index 0000000000000..4fc310114d752 --- /dev/null +++ b/src/hooks/useViewTourTask.ts @@ -0,0 +1,16 @@ +import {isArchivedReport} from '@libs/ReportUtils'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import useOnyx from './useOnyx'; + +function useViewTourTask() { + const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); + const viewTourTaskReportID = introSelected?.[CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR]; + const [viewTourTaskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourTaskReportID}`, {canBeMissing: true}, [viewTourTaskReportID]); + const [viewTourTaskParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourTaskReport?.parentReportID}`, {canBeMissing: true}); + const [viewTourTaskParentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${viewTourTaskParentReport?.reportID}`, {canBeMissing: true}); + + return {isViewTourParentReportAcrhived: isArchivedReport(viewTourTaskParentReportNameValuePairs)}; +} + +export default useViewTourTask; diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 0bb6b5cd8ef08..e1db411909ebf 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -89,7 +89,7 @@ Onyx.connect({ callback: (val) => (introSelected = val), }); -let allReportNameValuePair: OnyxCollection; +// let allReportNameValuePair: OnyxCollection; // allReportNameValuePair is used on getFinishOnboardingTaskOnyxData to generate Onyx optimistic data Onyx.connectWithoutView({ key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, @@ -1313,12 +1313,10 @@ function clearTaskErrors(reportID: string | undefined) { }); } -function getFinishOnboardingTaskOnyxData(taskName: IntroSelectedTask): OnyxData { +function getFinishOnboardingTaskOnyxData(taskName: IntroSelectedTask, isParentReportArchived: boolean): OnyxData { const taskReportID = introSelected?.[taskName]; const taskReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`]; const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${taskReport?.parentReportID}`]; - const parentReportNameValuePairs = allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${parentReport?.reportID}`]; - const isParentReportArchived = ReportUtils.isArchivedReport(parentReportNameValuePairs); if (taskReportID && canActionTask(taskReport, currentUserAccountID, parentReport, isParentReportArchived)) { if (taskReport) { if (taskReport.stateNum !== CONST.REPORT.STATE_NUM.APPROVED || taskReport.statusNum !== CONST.REPORT.STATUS_NUM.APPROVED) { @@ -1329,9 +1327,9 @@ function getFinishOnboardingTaskOnyxData(taskName: IntroSelectedTask): OnyxData return {}; } -function completeTestDriveTask(shouldUpdateSelfTourViewedOnlyLocally = false) { +function completeTestDriveTask(isTaskParentReportArchived: boolean, shouldUpdateSelfTourViewedOnlyLocally = false) { setSelfTourViewed(shouldUpdateSelfTourViewedOnlyLocally); - getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR, isTaskParentReportArchived); } export { diff --git a/src/libs/actions/Tour.ts b/src/libs/actions/Tour.ts index 6873ee3d5163f..b685d391c394b 100644 --- a/src/libs/actions/Tour.ts +++ b/src/libs/actions/Tour.ts @@ -10,6 +10,7 @@ function startTestDrive( shouldUpdateSelfTourViewedOnlyLocally: boolean, hasUserBeenAddedToNudgeMigration: boolean, isUserPaidPolicyMember: boolean, + isViewTourTaskParentReportArchived: boolean, ) { InteractionManager.runAfterInteractions(() => { if ( @@ -20,7 +21,7 @@ function startTestDrive( introSelected?.choice === CONST.ONBOARDING_CHOICES.TRACK_WORKSPACE || (introSelected?.choice === CONST.ONBOARDING_CHOICES.SUBMIT && introSelected.inviteType === CONST.ONBOARDING_INVITE_TYPES.WORKSPACE) ) { - completeTestDriveTask(shouldUpdateSelfTourViewedOnlyLocally); + completeTestDriveTask(isViewTourTaskParentReportArchived, shouldUpdateSelfTourViewedOnlyLocally); Navigation.navigate(ROUTES.TEST_DRIVE_DEMO_ROOT); } else { Navigation.navigate(ROUTES.TEST_DRIVE_MODAL_ROOT.route); diff --git a/src/pages/Search/EmptySearchView.tsx b/src/pages/Search/EmptySearchView.tsx index 2db8255c0093b..d5bbb9308d5e6 100644 --- a/src/pages/Search/EmptySearchView.tsx +++ b/src/pages/Search/EmptySearchView.tsx @@ -26,6 +26,7 @@ import useSearchTypeMenuSections from '@hooks/useSearchTypeMenuSections'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import useViewTourTask from '@hooks/useViewTourTask'; import {startMoneyRequest} from '@libs/actions/IOU'; import {openOldDotLink} from '@libs/actions/Link'; import {createNewReport} from '@libs/actions/Report'; @@ -173,6 +174,8 @@ function EmptySearchViewContent({ }); const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {selector: tryNewDotOnyxSelector, canBeMissing: true}); + const {isViewTourParentReportAcrhived} = useViewTourTask(); + const shouldRedirectToExpensifyClassic = useMemo(() => { return areAllGroupPoliciesExpenseChatDisabled(allPolicies ?? {}); }, [allPolicies]); @@ -269,7 +272,7 @@ function EmptySearchViewContent({ } const startTestDriveAction = () => { - startTestDrive(introSelected, false, tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember); + startTestDrive(introSelected, false, tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember, isViewTourParentReportAcrhived); }; // If we are grouping by reports, show a custom message rather than a type-specific message diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index 15da6a90cfb89..2f3c28bc8c91a 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -22,6 +22,7 @@ import useReportIsArchived from '@hooks/useReportIsArchived'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import useViewTourTask from '@hooks/useViewTourTask'; import useWindowDimensions from '@hooks/useWindowDimensions'; import {startDistanceRequest, startMoneyRequest} from '@libs/actions/IOU'; import {openOldDotLink} from '@libs/actions/Link'; @@ -152,6 +153,8 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref selector: (policies) => Object.values(policies ?? {}).some((policy) => isPaidGroupPolicy(policy) && isPolicyMember(policy, currentUserPersonalDetails.login)), }); + const {isViewTourParentReportAcrhived} = useViewTourTask(); + const isReportInSearch = isOnSearchMoneyRequestReportPage(); const groupPoliciesWithChatEnabled = getGroupPaidPoliciesWithExpenseChatEnabled(); @@ -557,7 +560,9 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref iconFill: theme.icon, text: translate('testDrive.quickAction.takeATwoMinuteTestDrive'), onSelected: () => - interceptAnonymousUser(() => startTestDrive(introSelected, isAnonymousUser(), tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember)), + interceptAnonymousUser(() => + startTestDrive(introSelected, isAnonymousUser(), tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember, isViewTourParentReportAcrhived), + ), }, ] : []), diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 6963fbd3c9a85..a7fdbc5e125a0 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -24,6 +24,7 @@ import useParticipantsInvoiceReport from '@hooks/useParticipantsInvoiceReport'; import usePermissions from '@hooks/usePermissions'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import useViewTourTask from '@hooks/useViewTourTask'; import {completeTestDriveTask} from '@libs/actions/Task'; import DateUtils from '@libs/DateUtils'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; @@ -192,6 +193,8 @@ function IOURequestStepConfirmation({ const isPerDiemRequest = requestType === CONST.IOU.REQUEST_TYPE.PER_DIEM; const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: true}); + const {isViewTourParentReportAcrhived} = useViewTourTask(); + const [archivedReportsIdSet = new Set()] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { canBeMissing: true, selector: (all): ArchivedReportsIDSet => { @@ -500,7 +503,7 @@ function IOURequestStepConfirmation({ !!item.linkedTrackedExpenseReportID && archivedReportsIdSet.has(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${item.linkedTrackedExpenseReportID}`); if (isTestDriveReceipt) { - completeTestDriveTask(); + completeTestDriveTask(isViewTourParentReportAcrhived); } requestMoneyIOUActions({ From ce61da9f80d54da3460b1d39328bc3599319aaac Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 15:44:49 +0530 Subject: [PATCH 03/15] Rename task hook --- src/components/TestDrive/TestDriveDemo.tsx | 4 ++-- src/hooks/useOnboardingTask.ts | 17 +++++++++++++++++ src/hooks/useViewTourTask.ts | 16 ---------------- src/pages/Search/EmptySearchView.tsx | 4 ++-- .../sidebar/FloatingActionButtonAndPopover.tsx | 4 ++-- .../request/step/IOURequestStepConfirmation.tsx | 4 ++-- 6 files changed, 25 insertions(+), 24 deletions(-) create mode 100644 src/hooks/useOnboardingTask.ts delete mode 100644 src/hooks/useViewTourTask.ts diff --git a/src/components/TestDrive/TestDriveDemo.tsx b/src/components/TestDrive/TestDriveDemo.tsx index b555a59c16e5c..8bff88adcb96f 100644 --- a/src/components/TestDrive/TestDriveDemo.tsx +++ b/src/components/TestDrive/TestDriveDemo.tsx @@ -6,10 +6,10 @@ import Modal from '@components/Modal'; import SafeAreaConsumer from '@components/SafeAreaConsumer'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useOnboardingMessages from '@hooks/useOnboardingMessages'; +import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; -import useViewTourTask from '@hooks/useViewTourTask'; import {completeTestDriveTask} from '@libs/actions/Task'; import Navigation from '@libs/Navigation/Navigation'; import {isPaidGroupPolicy, isPolicyAdmin} from '@libs/PolicyUtils'; @@ -28,7 +28,7 @@ function TestDriveDemo() { const [onboardingReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${onboarding?.chatReportID}`, {canBeMissing: true}); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); - const {isViewTourParentReportAcrhived} = useViewTourTask(); + const {isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const {testDrive} = useOnboardingMessages(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); diff --git a/src/hooks/useOnboardingTask.ts b/src/hooks/useOnboardingTask.ts new file mode 100644 index 0000000000000..4c625e8a44a03 --- /dev/null +++ b/src/hooks/useOnboardingTask.ts @@ -0,0 +1,17 @@ +import {isArchivedReport} from '@libs/ReportUtils'; +import ONYXKEYS from '@src/ONYXKEYS'; +import type {IntroSelectedTask} from '@src/types/onyx/IntroSelected'; +import useOnyx from './useOnyx'; + +function useOnboardingTask(taskName: IntroSelectedTask) { + const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); + // const viewTourTaskReportID = introSelected?.[CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR]; + const taskReportID = introSelected?.[taskName]; + const [taskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, {canBeMissing: true}, [taskReportID]); + const [taskParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReport?.parentReportID}`, {canBeMissing: true}); + const [taskParentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${taskParentReport?.reportID}`, {canBeMissing: true}); + + return {isViewTourParentReportAcrhived: isArchivedReport(taskParentReportNameValuePairs)}; +} + +export default useOnboardingTask; diff --git a/src/hooks/useViewTourTask.ts b/src/hooks/useViewTourTask.ts deleted file mode 100644 index 4fc310114d752..0000000000000 --- a/src/hooks/useViewTourTask.ts +++ /dev/null @@ -1,16 +0,0 @@ -import {isArchivedReport} from '@libs/ReportUtils'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import useOnyx from './useOnyx'; - -function useViewTourTask() { - const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); - const viewTourTaskReportID = introSelected?.[CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR]; - const [viewTourTaskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourTaskReportID}`, {canBeMissing: true}, [viewTourTaskReportID]); - const [viewTourTaskParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourTaskReport?.parentReportID}`, {canBeMissing: true}); - const [viewTourTaskParentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${viewTourTaskParentReport?.reportID}`, {canBeMissing: true}); - - return {isViewTourParentReportAcrhived: isArchivedReport(viewTourTaskParentReportNameValuePairs)}; -} - -export default useViewTourTask; diff --git a/src/pages/Search/EmptySearchView.tsx b/src/pages/Search/EmptySearchView.tsx index d5bbb9308d5e6..4b91bf2ec93f0 100644 --- a/src/pages/Search/EmptySearchView.tsx +++ b/src/pages/Search/EmptySearchView.tsx @@ -21,12 +21,12 @@ import Text from '@components/Text'; import TextLink from '@components/TextLink'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; +import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import useSearchTypeMenuSections from '@hooks/useSearchTypeMenuSections'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import useViewTourTask from '@hooks/useViewTourTask'; import {startMoneyRequest} from '@libs/actions/IOU'; import {openOldDotLink} from '@libs/actions/Link'; import {createNewReport} from '@libs/actions/Report'; @@ -174,7 +174,7 @@ function EmptySearchViewContent({ }); const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {selector: tryNewDotOnyxSelector, canBeMissing: true}); - const {isViewTourParentReportAcrhived} = useViewTourTask(); + const {isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const shouldRedirectToExpensifyClassic = useMemo(() => { return areAllGroupPoliciesExpenseChatDisabled(allPolicies ?? {}); diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index 2f3c28bc8c91a..a0b3402e33915 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -15,6 +15,7 @@ import PopoverMenu from '@components/PopoverMenu'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import usePermissions from '@hooks/usePermissions'; import usePrevious from '@hooks/usePrevious'; @@ -22,7 +23,6 @@ import useReportIsArchived from '@hooks/useReportIsArchived'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import useViewTourTask from '@hooks/useViewTourTask'; import useWindowDimensions from '@hooks/useWindowDimensions'; import {startDistanceRequest, startMoneyRequest} from '@libs/actions/IOU'; import {openOldDotLink} from '@libs/actions/Link'; @@ -153,7 +153,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref selector: (policies) => Object.values(policies ?? {}).some((policy) => isPaidGroupPolicy(policy) && isPolicyMember(policy, currentUserPersonalDetails.login)), }); - const {isViewTourParentReportAcrhived} = useViewTourTask(); + const {isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const isReportInSearch = isOnSearchMoneyRequestReportPage(); diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index a7fdbc5e125a0..10a8760520de4 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -19,12 +19,12 @@ import useFetchRoute from '@hooks/useFetchRoute'; import useFilesValidation from '@hooks/useFilesValidation'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import useParticipantsInvoiceReport from '@hooks/useParticipantsInvoiceReport'; import usePermissions from '@hooks/usePermissions'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import useViewTourTask from '@hooks/useViewTourTask'; import {completeTestDriveTask} from '@libs/actions/Task'; import DateUtils from '@libs/DateUtils'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; @@ -193,7 +193,7 @@ function IOURequestStepConfirmation({ const isPerDiemRequest = requestType === CONST.IOU.REQUEST_TYPE.PER_DIEM; const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: true}); - const {isViewTourParentReportAcrhived} = useViewTourTask(); + const {isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const [archivedReportsIdSet = new Set()] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { canBeMissing: true, From 5db0dd9eb0b5f85610e536689f145c1cf5b4b5aa Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 15:52:17 +0530 Subject: [PATCH 04/15] Refactor getFinishOnboardingTaskOnyxData --- src/hooks/useOnboardingTask.ts | 2 +- src/libs/actions/Policy/Category.ts | 14 ++++++++------ .../workspace/categories/CategorySettingsPage.tsx | 12 ++++++++++-- .../workspace/categories/CreateCategoryPage.tsx | 6 ++++-- .../categories/WorkspaceCategoriesPage.tsx | 13 ++++++++----- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/hooks/useOnboardingTask.ts b/src/hooks/useOnboardingTask.ts index 4c625e8a44a03..7e1329be96819 100644 --- a/src/hooks/useOnboardingTask.ts +++ b/src/hooks/useOnboardingTask.ts @@ -11,7 +11,7 @@ function useOnboardingTask(taskName: IntroSelectedTask) { const [taskParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReport?.parentReportID}`, {canBeMissing: true}); const [taskParentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${taskParentReport?.reportID}`, {canBeMissing: true}); - return {isViewTourParentReportAcrhived: isArchivedReport(taskParentReportNameValuePairs)}; + return {isParentReportAcrhived: isArchivedReport(taskParentReportNameValuePairs)}; } export default useOnboardingTask; diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index 2a23deae43041..886c286646047 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -52,8 +52,8 @@ Onyx.connect({ callback: (val) => (allPolicyCategories = val), }); -function appendSetupCategoriesOnboardingData(onyxData: OnyxData) { - const finishOnboardingTaskData = getFinishOnboardingTaskOnyxData('setupCategories'); +function appendSetupCategoriesOnboardingData(onyxData: OnyxData, isSetupCategoriesTaskParentReportArchived: boolean) { + const finishOnboardingTaskData = getFinishOnboardingTaskOnyxData('setupCategories', isSetupCategoriesTaskParentReportArchived); onyxData.optimisticData?.push(...(finishOnboardingTaskData.optimisticData ?? [])); onyxData.successData?.push(...(finishOnboardingTaskData.successData ?? [])); onyxData.failureData?.push(...(finishOnboardingTaskData.failureData ?? [])); @@ -329,6 +329,7 @@ function buildOptimisticPolicyRecentlyUsedCategories(policyID?: string, category function setWorkspaceCategoryEnabled( policyID: string, categoriesToUpdate: Record, + isSetupCategoriesTaskParentReportArchived: boolean, policyTagLists: PolicyTagLists = {}, allTransactionViolations: OnyxCollection = {}, ) { @@ -398,7 +399,7 @@ function setWorkspaceCategoryEnabled( }; pushTransactionViolationsOnyxData(onyxData, policyID, policyTagLists, policyCategories, allTransactionViolations, {}, optimisticPolicyCategoriesData); - appendSetupCategoriesOnboardingData(onyxData); + appendSetupCategoriesOnboardingData(onyxData, isSetupCategoriesTaskParentReportArchived); const parameters = { policyID, @@ -598,9 +599,9 @@ function removePolicyCategoryReceiptsRequired(policyID: string, categoryName: st API.write(WRITE_COMMANDS.REMOVE_POLICY_CATEGORY_RECEIPTS_REQUIRED, parameters, onyxData); } -function createPolicyCategory(policyID: string, categoryName: string) { +function createPolicyCategory(policyID: string, categoryName: string, isSetupCategoriesTaskParentReportArchived: boolean) { const onyxData = buildOptimisticPolicyCategories(policyID, [categoryName]); - appendSetupCategoriesOnboardingData(onyxData); + appendSetupCategoriesOnboardingData(onyxData, isSetupCategoriesTaskParentReportArchived); const parameters = { policyID, categories: JSON.stringify([{name: categoryName}]), @@ -978,6 +979,7 @@ function clearCategoryErrors(policyID: string, categoryName: string) { function deleteWorkspaceCategories( policyID: string, categoryNamesToDelete: string[], + isSetupCategoriesTaskParentReportArchived: boolean, policyTagLists: PolicyTagLists = {}, transactionViolations: OnyxCollection = {}, ) { @@ -1027,7 +1029,7 @@ function deleteWorkspaceCategories( const optimisticPolicyData: Partial = shouldDisableRequiresCategory ? {requiresCategory: false} : {}; pushTransactionViolationsOnyxData(onyxData, policyID, policyTagLists, policyCategories, transactionViolations, optimisticPolicyData, optimisticPolicyCategoriesData); - appendSetupCategoriesOnboardingData(onyxData); + appendSetupCategoriesOnboardingData(onyxData, isSetupCategoriesTaskParentReportArchived); const parameters = { policyID, diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index 5bfdcca4aad4e..ed6ae1348910a 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -13,6 +13,7 @@ import Switch from '@components/Switch'; import Text from '@components/Text'; import useEnvironment from '@hooks/useEnvironment'; import useLocalize from '@hooks/useLocalize'; +import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import usePolicy from '@hooks/usePolicy'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -67,6 +68,7 @@ function CategorySettingsPage({ const shouldPreventDisableOrDelete = isDisablingOrDeletingLastEnabledCategory(policy, policyCategories, [policyCategory]); const areCommentsRequired = policyCategory?.areCommentsRequired ?? false; const isQuickSettingsFlow = name === SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORY_SETTINGS; + const {isParentReportAcrhived: isSetupCategoryTaskParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); const navigateBack = () => { Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(policyID, backTo) : undefined); @@ -129,7 +131,13 @@ function CategorySettingsPage({ setIsCannotDeleteOrDisableLastCategoryModalVisible(true); return; } - setWorkspaceCategoryEnabled(policyID, {[policyCategory.name]: {name: policyCategory.name, enabled: value}}, policyTagLists, allTransactionViolations); + setWorkspaceCategoryEnabled( + policyID, + {[policyCategory.name]: {name: policyCategory.name, enabled: value}}, + isSetupCategoryTaskParentReportAcrhived, + policyTagLists, + allTransactionViolations, + ); }; const navigateToEditCategory = () => { @@ -139,7 +147,7 @@ function CategorySettingsPage({ }; const deleteCategory = () => { - deleteWorkspaceCategories(policyID, [categoryName], policyTagLists, allTransactionViolations); + deleteWorkspaceCategories(policyID, [categoryName], isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations); setDeleteCategoryConfirmModalVisible(false); navigateBack(); }; diff --git a/src/pages/workspace/categories/CreateCategoryPage.tsx b/src/pages/workspace/categories/CreateCategoryPage.tsx index e0f5989ce2bf5..fbd3f2b5f0278 100644 --- a/src/pages/workspace/categories/CreateCategoryPage.tsx +++ b/src/pages/workspace/categories/CreateCategoryPage.tsx @@ -3,6 +3,7 @@ import type {FormOnyxValues} from '@components/Form/types'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import useLocalize from '@hooks/useLocalize'; +import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; import {createPolicyCategory} from '@libs/actions/Policy/Category'; @@ -26,13 +27,14 @@ function CreateCategoryPage({route}: CreateCategoryPageProps) { const {translate} = useLocalize(); const backTo = route.params?.backTo; const isQuickSettingsFlow = route.name === SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORY_CREATE; + const {isParentReportAcrhived: isSetupCategoryTaskParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); const createCategory = useCallback( (values: FormOnyxValues) => { - createPolicyCategory(route.params.policyID, values.categoryName.trim()); + createPolicyCategory(route.params.policyID, values.categoryName.trim(), isSetupCategoryTaskParentReportAcrhived); Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(route.params.policyID, backTo) : undefined); }, - [isQuickSettingsFlow, route.params.policyID, backTo], + [route.params.policyID, isSetupCategoryTaskParentReportAcrhived, isQuickSettingsFlow, backTo], ); return ( diff --git a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx index 472fac0a55e69..7f25747238b8a 100644 --- a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx +++ b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx @@ -29,6 +29,7 @@ import useEnvironment from '@hooks/useEnvironment'; import useLocalize from '@hooks/useLocalize'; import useMobileSelectionMode from '@hooks/useMobileSelectionMode'; import useNetwork from '@hooks/useNetwork'; +import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import usePolicy from '@hooks/usePolicy'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; @@ -91,6 +92,8 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { const [selectedCategories, setSelectedCategories] = useState([]); const canSelectMultiple = isSmallScreenWidth ? isMobileSelectionModeEnabled : true; + const {isParentReportAcrhived: isSetupCategoryTaskParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); + const fetchCategories = useCallback(() => { openPolicyCategoriesPage(policyId); }, [policyId]); @@ -141,9 +144,9 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { const updateWorkspaceCategoryEnabled = useCallback( (value: boolean, categoryName: string) => { - setWorkspaceCategoryEnabled(policyId, {[categoryName]: {name: categoryName, enabled: value}}, policyTagLists, allTransactionViolations); + setWorkspaceCategoryEnabled(policyId, {[categoryName]: {name: categoryName, enabled: value}}, isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations); }, - [policyId, policyTagLists, allTransactionViolations], + [policyId, isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations], ); const categoryList = useMemo(() => { @@ -254,7 +257,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { }; const handleDeleteCategories = () => { - deleteWorkspaceCategories(policyId, selectedCategories, policyTagLists, allTransactionViolations); + deleteWorkspaceCategories(policyId, selectedCategories, isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations); setDeleteCategoriesConfirmModalVisible(false); InteractionManager.runAfterInteractions(() => { @@ -358,7 +361,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { return; } setSelectedCategories([]); - setWorkspaceCategoryEnabled(policyId, categoriesToDisable, policyTagLists, allTransactionViolations); + setWorkspaceCategoryEnabled(policyId, categoriesToDisable, isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations); }, }); } @@ -380,7 +383,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { value: CONST.POLICY.BULK_ACTION_TYPES.ENABLE, onSelected: () => { setSelectedCategories([]); - setWorkspaceCategoryEnabled(policyId, categoriesToEnable, policyTagLists, allTransactionViolations); + setWorkspaceCategoryEnabled(policyId, categoriesToEnable, isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations); }, }); } From a227458579066ce0228511da6b28f2be2deb31c3 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 15:52:44 +0530 Subject: [PATCH 05/15] Remove extra key --- src/libs/actions/Task.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index e1db411909ebf..a0672961f9cb0 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -89,19 +89,6 @@ Onyx.connect({ callback: (val) => (introSelected = val), }); -// let allReportNameValuePair: OnyxCollection; -// allReportNameValuePair is used on getFinishOnboardingTaskOnyxData to generate Onyx optimistic data -Onyx.connectWithoutView({ - key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, - waitForCollectionCallback: true, - callback: (value) => { - if (!value) { - return; - } - allReportNameValuePair = value; - }, -}); - /** * Clears out the task info from the store */ From 833f846c586f0de0b78ebd707f3f323f1d18bbd5 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 15:53:25 +0530 Subject: [PATCH 06/15] Remove comments --- src/hooks/useOnboardingTask.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hooks/useOnboardingTask.ts b/src/hooks/useOnboardingTask.ts index 7e1329be96819..9cbdbd8b6290a 100644 --- a/src/hooks/useOnboardingTask.ts +++ b/src/hooks/useOnboardingTask.ts @@ -5,7 +5,6 @@ import useOnyx from './useOnyx'; function useOnboardingTask(taskName: IntroSelectedTask) { const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); - // const viewTourTaskReportID = introSelected?.[CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR]; const taskReportID = introSelected?.[taskName]; const [taskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, {canBeMissing: true}, [taskReportID]); const [taskParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReport?.parentReportID}`, {canBeMissing: true}); From d7c06cade808de2c2af9933998a2bff41712e3a5 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 15:54:25 +0530 Subject: [PATCH 07/15] rename --- src/components/TestDrive/TestDriveDemo.tsx | 2 +- src/pages/Search/EmptySearchView.tsx | 2 +- src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx | 2 +- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/TestDrive/TestDriveDemo.tsx b/src/components/TestDrive/TestDriveDemo.tsx index 8bff88adcb96f..c27b71f714774 100644 --- a/src/components/TestDrive/TestDriveDemo.tsx +++ b/src/components/TestDrive/TestDriveDemo.tsx @@ -28,7 +28,7 @@ function TestDriveDemo() { const [onboardingReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${onboarding?.chatReportID}`, {canBeMissing: true}); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); - const {isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const {isParentReportAcrhived: isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const {testDrive} = useOnboardingMessages(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); diff --git a/src/pages/Search/EmptySearchView.tsx b/src/pages/Search/EmptySearchView.tsx index 4b91bf2ec93f0..511898482a00f 100644 --- a/src/pages/Search/EmptySearchView.tsx +++ b/src/pages/Search/EmptySearchView.tsx @@ -174,7 +174,7 @@ function EmptySearchViewContent({ }); const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {selector: tryNewDotOnyxSelector, canBeMissing: true}); - const {isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const {isParentReportAcrhived: isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const shouldRedirectToExpensifyClassic = useMemo(() => { return areAllGroupPoliciesExpenseChatDisabled(allPolicies ?? {}); diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index a0b3402e33915..36ac47a3b008b 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -153,7 +153,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref selector: (policies) => Object.values(policies ?? {}).some((policy) => isPaidGroupPolicy(policy) && isPolicyMember(policy, currentUserPersonalDetails.login)), }); - const {isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const {isParentReportAcrhived: isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const isReportInSearch = isOnSearchMoneyRequestReportPage(); diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 10a8760520de4..d32b963e4ea49 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -193,7 +193,7 @@ function IOURequestStepConfirmation({ const isPerDiemRequest = requestType === CONST.IOU.REQUEST_TYPE.PER_DIEM; const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: true}); - const {isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const {isParentReportAcrhived: isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const [archivedReportsIdSet = new Set()] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { canBeMissing: true, From 81aca4c11d3144926caabafc8b7efc1f08e90083 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 16:14:18 +0530 Subject: [PATCH 08/15] Update tests --- tests/actions/PolicyCategoryTest.ts | 6 +++--- tests/actions/TaskTest.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/actions/PolicyCategoryTest.ts b/tests/actions/PolicyCategoryTest.ts index 351adaf8e982c..591ca1b7e8753 100644 --- a/tests/actions/PolicyCategoryTest.ts +++ b/tests/actions/PolicyCategoryTest.ts @@ -71,7 +71,7 @@ describe('actions/PolicyCategory', () => { mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, fakeCategories); - Category.createPolicyCategory(fakePolicy.id, newCategoryName); + Category.createPolicyCategory(fakePolicy.id, newCategoryName, false); await waitForBatchedUpdates(); await new Promise((resolve) => { const connection = Onyx.connect({ @@ -169,7 +169,7 @@ describe('actions/PolicyCategory', () => { mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, fakeCategories); - Category.setWorkspaceCategoryEnabled(fakePolicy.id, categoriesToUpdate); + Category.setWorkspaceCategoryEnabled(fakePolicy.id, categoriesToUpdate, false); await waitForBatchedUpdates(); await new Promise((resolve) => { const connection = Onyx.connect({ @@ -214,7 +214,7 @@ describe('actions/PolicyCategory', () => { mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, fakeCategories); - Category.deleteWorkspaceCategories(fakePolicy.id, categoriesToDelete); + Category.deleteWorkspaceCategories(fakePolicy.id, categoriesToDelete, false); await waitForBatchedUpdates(); await new Promise((resolve) => { const connection = Onyx.connect({ diff --git a/tests/actions/TaskTest.ts b/tests/actions/TaskTest.ts index 99e0cae6e7ab9..88198f21fde4a 100644 --- a/tests/actions/TaskTest.ts +++ b/tests/actions/TaskTest.ts @@ -272,8 +272,8 @@ describe('actions/Task', () => { }); it('Completes test drive task', () => { - completeTestDriveTask(); - expect(Object.values(getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR)).length).toBe(0); + completeTestDriveTask(false); + expect(Object.values(getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR, false)).length).toBe(0); }); }); @@ -294,7 +294,7 @@ describe('actions/Task', () => { await waitForBatchedUpdates(); }); it('Return not empty object', () => { - expect(Object.values(getFinishOnboardingTaskOnyxData('setupCategories')).length).toBeGreaterThan(0); + expect(Object.values(getFinishOnboardingTaskOnyxData('setupCategories', false)).length).toBeGreaterThan(0); }); it('Return empty object', async () => { const reportNameValuePairs = { @@ -302,7 +302,7 @@ describe('actions/Task', () => { }; await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${parentReport.reportID}`, reportNameValuePairs); await waitForBatchedUpdates(); - expect(Object.values(getFinishOnboardingTaskOnyxData('setupCategories')).length).toBe(0); + expect(Object.values(getFinishOnboardingTaskOnyxData('setupCategories', false)).length).toBe(0); }); }); From f5444c79f7cf2c940dace30e8d39c58b5630e921 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 16:34:02 +0530 Subject: [PATCH 09/15] fix tasks --- tests/actions/TourTest.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/actions/TourTest.ts b/tests/actions/TourTest.ts index f407fd4ee0907..bc40c4bbd55b9 100644 --- a/tests/actions/TourTest.ts +++ b/tests/actions/TourTest.ts @@ -41,14 +41,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); + startTestDrive(undefined, false, true, false, false); await waitForBatchedUpdates(); expect(Navigation.navigate).toBeCalledWith(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); + startTestDrive(undefined, false, false, true, false); await waitForBatchedUpdates(); expect(Navigation.navigate).toBeCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); @@ -96,16 +96,16 @@ 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); + startTestDrive({choice}, false, false, false, false); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); // An empty object means the task was completed. - expect(Object.values(getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR)).length).toBe(0); + expect(Object.values(getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR, false)).length).toBe(0); }); 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); + startTestDrive({choice}, false, false, false, false); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_MODAL_ROOT.route); @@ -114,16 +114,16 @@ 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); + startTestDrive({choice: CONST.ONBOARDING_CHOICES.SUBMIT, inviteType: CONST.ONBOARDING_INVITE_TYPES.WORKSPACE}, false, false, false, false); await waitForBatchedUpdates(); expect(Navigation.navigate).toBeCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); // An empty object means the task was completed. - expect(Object.values(getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR)).length).toBe(0); + expect(Object.values(getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR, false)).length).toBe(0); }); 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); + startTestDrive({choice: CONST.ONBOARDING_CHOICES.LOOKING_AROUND}, false, false, true, false); await waitForBatchedUpdates(); expect(Navigation.navigate).toBeCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); From f9f8fcbeeb4aa358babc41735af7664e7c410709 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 16:45:07 +0530 Subject: [PATCH 10/15] Rename and refactor --- src/components/TestDrive/TestDriveDemo.tsx | 4 ++-- src/hooks/useOnboardingTask.ts | 2 +- src/pages/Search/EmptySearchView.tsx | 4 ++-- .../home/sidebar/FloatingActionButtonAndPopover.tsx | 4 ++-- .../iou/request/step/IOURequestStepConfirmation.tsx | 4 ++-- .../workspace/categories/CategorySettingsPage.tsx | 6 +++--- .../workspace/categories/CreateCategoryPage.tsx | 6 +++--- .../workspace/categories/WorkspaceCategoriesPage.tsx | 12 ++++++------ tests/actions/TourTest.ts | 9 +++++---- 9 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/components/TestDrive/TestDriveDemo.tsx b/src/components/TestDrive/TestDriveDemo.tsx index c27b71f714774..4e9ed3f781448 100644 --- a/src/components/TestDrive/TestDriveDemo.tsx +++ b/src/components/TestDrive/TestDriveDemo.tsx @@ -28,7 +28,7 @@ function TestDriveDemo() { const [onboardingReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${onboarding?.chatReportID}`, {canBeMissing: true}); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); - const {isParentReportAcrhived: isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const {isParentReportArchived: isViewTourParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const {testDrive} = useOnboardingMessages(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); @@ -40,7 +40,7 @@ function TestDriveDemo() { useEffect(() => { InteractionManager.runAfterInteractions(() => { setIsVisible(true); - completeTestDriveTask(isViewTourParentReportAcrhived); + completeTestDriveTask(isViewTourParentReportArchived); }); // This should fire only during mount. diff --git a/src/hooks/useOnboardingTask.ts b/src/hooks/useOnboardingTask.ts index 9cbdbd8b6290a..f4cd2404fa234 100644 --- a/src/hooks/useOnboardingTask.ts +++ b/src/hooks/useOnboardingTask.ts @@ -10,7 +10,7 @@ function useOnboardingTask(taskName: IntroSelectedTask) { const [taskParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReport?.parentReportID}`, {canBeMissing: true}); const [taskParentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${taskParentReport?.reportID}`, {canBeMissing: true}); - return {isParentReportAcrhived: isArchivedReport(taskParentReportNameValuePairs)}; + return {isParentReportArchived: isArchivedReport(taskParentReportNameValuePairs)}; } export default useOnboardingTask; diff --git a/src/pages/Search/EmptySearchView.tsx b/src/pages/Search/EmptySearchView.tsx index 511898482a00f..83b84e47aedbe 100644 --- a/src/pages/Search/EmptySearchView.tsx +++ b/src/pages/Search/EmptySearchView.tsx @@ -174,7 +174,7 @@ function EmptySearchViewContent({ }); const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {selector: tryNewDotOnyxSelector, canBeMissing: true}); - const {isParentReportAcrhived: isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const {isParentReportArchived: isViewTourParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const shouldRedirectToExpensifyClassic = useMemo(() => { return areAllGroupPoliciesExpenseChatDisabled(allPolicies ?? {}); @@ -272,7 +272,7 @@ function EmptySearchViewContent({ } const startTestDriveAction = () => { - startTestDrive(introSelected, false, tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember, isViewTourParentReportAcrhived); + startTestDrive(introSelected, false, tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember, isViewTourParentReportArchived); }; // If we are grouping by reports, show a custom message rather than a type-specific message diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index 36ac47a3b008b..9e42cbda744c5 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -153,7 +153,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref selector: (policies) => Object.values(policies ?? {}).some((policy) => isPaidGroupPolicy(policy) && isPolicyMember(policy, currentUserPersonalDetails.login)), }); - const {isParentReportAcrhived: isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const {isParentReportArchived: isViewTourParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const isReportInSearch = isOnSearchMoneyRequestReportPage(); @@ -561,7 +561,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref text: translate('testDrive.quickAction.takeATwoMinuteTestDrive'), onSelected: () => interceptAnonymousUser(() => - startTestDrive(introSelected, isAnonymousUser(), tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember, isViewTourParentReportAcrhived), + startTestDrive(introSelected, isAnonymousUser(), tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember, isViewTourParentReportArchived), ), }, ] diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index d32b963e4ea49..9d80daab009e0 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -193,7 +193,7 @@ function IOURequestStepConfirmation({ const isPerDiemRequest = requestType === CONST.IOU.REQUEST_TYPE.PER_DIEM; const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: true}); - const {isParentReportAcrhived: isViewTourParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const {isParentReportArchived: isViewTourParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const [archivedReportsIdSet = new Set()] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { canBeMissing: true, @@ -503,7 +503,7 @@ function IOURequestStepConfirmation({ !!item.linkedTrackedExpenseReportID && archivedReportsIdSet.has(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${item.linkedTrackedExpenseReportID}`); if (isTestDriveReceipt) { - completeTestDriveTask(isViewTourParentReportAcrhived); + completeTestDriveTask(isViewTourParentReportArchived); } requestMoneyIOUActions({ diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index ed6ae1348910a..eb926f9ab8992 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -68,7 +68,7 @@ function CategorySettingsPage({ const shouldPreventDisableOrDelete = isDisablingOrDeletingLastEnabledCategory(policy, policyCategories, [policyCategory]); const areCommentsRequired = policyCategory?.areCommentsRequired ?? false; const isQuickSettingsFlow = name === SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORY_SETTINGS; - const {isParentReportAcrhived: isSetupCategoryTaskParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); + const {isParentReportArchived: isSetupCategoryTaskParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); const navigateBack = () => { Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(policyID, backTo) : undefined); @@ -134,7 +134,7 @@ function CategorySettingsPage({ setWorkspaceCategoryEnabled( policyID, {[policyCategory.name]: {name: policyCategory.name, enabled: value}}, - isSetupCategoryTaskParentReportAcrhived, + isSetupCategoryTaskParentReportArchived, policyTagLists, allTransactionViolations, ); @@ -147,7 +147,7 @@ function CategorySettingsPage({ }; const deleteCategory = () => { - deleteWorkspaceCategories(policyID, [categoryName], isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations); + deleteWorkspaceCategories(policyID, [categoryName], isSetupCategoryTaskParentReportArchived, policyTagLists, allTransactionViolations); setDeleteCategoryConfirmModalVisible(false); navigateBack(); }; diff --git a/src/pages/workspace/categories/CreateCategoryPage.tsx b/src/pages/workspace/categories/CreateCategoryPage.tsx index fbd3f2b5f0278..9e1e2310e9cb2 100644 --- a/src/pages/workspace/categories/CreateCategoryPage.tsx +++ b/src/pages/workspace/categories/CreateCategoryPage.tsx @@ -27,14 +27,14 @@ function CreateCategoryPage({route}: CreateCategoryPageProps) { const {translate} = useLocalize(); const backTo = route.params?.backTo; const isQuickSettingsFlow = route.name === SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORY_CREATE; - const {isParentReportAcrhived: isSetupCategoryTaskParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); + const {isParentReportArchived: isSetupCategoryTaskParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); const createCategory = useCallback( (values: FormOnyxValues) => { - createPolicyCategory(route.params.policyID, values.categoryName.trim(), isSetupCategoryTaskParentReportAcrhived); + createPolicyCategory(route.params.policyID, values.categoryName.trim(), isSetupCategoryTaskParentReportArchived); Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(route.params.policyID, backTo) : undefined); }, - [route.params.policyID, isSetupCategoryTaskParentReportAcrhived, isQuickSettingsFlow, backTo], + [route.params.policyID, isSetupCategoryTaskParentReportArchived, isQuickSettingsFlow, backTo], ); return ( diff --git a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx index 7f25747238b8a..6f5902811dff6 100644 --- a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx +++ b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx @@ -92,7 +92,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { const [selectedCategories, setSelectedCategories] = useState([]); const canSelectMultiple = isSmallScreenWidth ? isMobileSelectionModeEnabled : true; - const {isParentReportAcrhived: isSetupCategoryTaskParentReportAcrhived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); + const {isParentReportArchived: isSetupCategoryTaskParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); const fetchCategories = useCallback(() => { openPolicyCategoriesPage(policyId); @@ -144,9 +144,9 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { const updateWorkspaceCategoryEnabled = useCallback( (value: boolean, categoryName: string) => { - setWorkspaceCategoryEnabled(policyId, {[categoryName]: {name: categoryName, enabled: value}}, isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations); + setWorkspaceCategoryEnabled(policyId, {[categoryName]: {name: categoryName, enabled: value}}, isSetupCategoryTaskParentReportArchived, policyTagLists, allTransactionViolations); }, - [policyId, isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations], + [policyId, isSetupCategoryTaskParentReportArchived, policyTagLists, allTransactionViolations], ); const categoryList = useMemo(() => { @@ -257,7 +257,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { }; const handleDeleteCategories = () => { - deleteWorkspaceCategories(policyId, selectedCategories, isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations); + deleteWorkspaceCategories(policyId, selectedCategories, isSetupCategoryTaskParentReportArchived, policyTagLists, allTransactionViolations); setDeleteCategoriesConfirmModalVisible(false); InteractionManager.runAfterInteractions(() => { @@ -361,7 +361,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { return; } setSelectedCategories([]); - setWorkspaceCategoryEnabled(policyId, categoriesToDisable, isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations); + setWorkspaceCategoryEnabled(policyId, categoriesToDisable, isSetupCategoryTaskParentReportArchived, policyTagLists, allTransactionViolations); }, }); } @@ -383,7 +383,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { value: CONST.POLICY.BULK_ACTION_TYPES.ENABLE, onSelected: () => { setSelectedCategories([]); - setWorkspaceCategoryEnabled(policyId, categoriesToEnable, isSetupCategoryTaskParentReportAcrhived, policyTagLists, allTransactionViolations); + setWorkspaceCategoryEnabled(policyId, categoriesToEnable, isSetupCategoryTaskParentReportArchived, policyTagLists, allTransactionViolations); }, }); } diff --git a/tests/actions/TourTest.ts b/tests/actions/TourTest.ts index bc40c4bbd55b9..fcf648b59b5c5 100644 --- a/tests/actions/TourTest.ts +++ b/tests/actions/TourTest.ts @@ -44,14 +44,14 @@ describe('actions/Tour', () => { startTestDrive(undefined, false, true, false, false); await waitForBatchedUpdates(); - expect(Navigation.navigate).toBeCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); + 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, false); await waitForBatchedUpdates(); - expect(Navigation.navigate).toBeCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); + expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); }); }); @@ -105,6 +105,7 @@ describe('actions/Tour', () => { }); it.each(onboardingChoices.filter((choice) => !onboardingDemoChoices.includes(choice)))('should show the Test Drive modal if user has "%s" onboarding choice', async (choice) => { + Acrhived; startTestDrive({choice}, false, false, false, false); await waitForBatchedUpdates(); @@ -117,7 +118,7 @@ describe('actions/Tour', () => { startTestDrive({choice: CONST.ONBOARDING_CHOICES.SUBMIT, inviteType: CONST.ONBOARDING_INVITE_TYPES.WORKSPACE}, false, false, false, false); await waitForBatchedUpdates(); - expect(Navigation.navigate).toBeCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); + expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); // An empty object means the task was completed. expect(Object.values(getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR, false)).length).toBe(0); }); @@ -126,7 +127,7 @@ describe('actions/Tour', () => { startTestDrive({choice: CONST.ONBOARDING_CHOICES.LOOKING_AROUND}, false, false, true, false); await waitForBatchedUpdates(); - expect(Navigation.navigate).toBeCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); + expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); }); }); }); From 1a97f39dd2f88457532bd9f9d99fb0df639019dd Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 16:54:23 +0530 Subject: [PATCH 11/15] remove extra word --- tests/actions/TourTest.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/actions/TourTest.ts b/tests/actions/TourTest.ts index fcf648b59b5c5..3a88773fb3165 100644 --- a/tests/actions/TourTest.ts +++ b/tests/actions/TourTest.ts @@ -105,7 +105,6 @@ describe('actions/Tour', () => { }); it.each(onboardingChoices.filter((choice) => !onboardingDemoChoices.includes(choice)))('should show the Test Drive modal if user has "%s" onboarding choice', async (choice) => { - Acrhived; startTestDrive({choice}, false, false, false, false); await waitForBatchedUpdates(); From 6befee39973464666a2a9c0e7ae36dc367e783f8 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 16:56:30 +0530 Subject: [PATCH 12/15] Reset warning count --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d9af716970d95..e91a473b4f990 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "test:debug": "TZ=utc NODE_OPTIONS='--inspect-brk --experimental-vm-modules' jest --runInBand", "perf-test": "NODE_OPTIONS=--experimental-vm-modules npx reassure", "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", - "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=183 --cache --cache-location=node_modules/.cache/eslint", + "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=182 --cache --cache-location=node_modules/.cache/eslint", "lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 ./scripts/lintChanged.sh", "lint-watch": "npx eslint-watch --watch --changed", "shellcheck": "./scripts/shellCheck.sh", From 8cc095209374daf83a0a180b97848f12c23057e7 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 18:22:17 +0530 Subject: [PATCH 13/15] Missing dependency --- src/pages/Search/EmptySearchView.tsx | 7 ++++--- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pages/Search/EmptySearchView.tsx b/src/pages/Search/EmptySearchView.tsx index 83b84e47aedbe..c16f610c91579 100644 --- a/src/pages/Search/EmptySearchView.tsx +++ b/src/pages/Search/EmptySearchView.tsx @@ -442,6 +442,9 @@ function EmptySearchViewContent({ styles.textAlignLeft, styles.tripEmptyStateLottieWebView, introSelected, + tryNewDot?.hasBeenAddedToNudgeMigration, + isUserPaidPolicyMember, + isViewTourParentReportArchived, hasResults, defaultViewItemHeader, hasSeenTour, @@ -450,10 +453,8 @@ function EmptySearchViewContent({ activePolicyID, currentUserPersonalDetails, tripViewChildren, - shouldRedirectToExpensifyClassic, hasTransactions, - tryNewDot?.hasBeenAddedToNudgeMigration, - isUserPaidPolicyMember, + shouldRedirectToExpensifyClassic, ]); return ( diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 9d80daab009e0..a5d77a2fce76a 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -555,9 +555,10 @@ function IOURequestStepConfirmation({ }); }, [ - report, transactions, receiptFiles, + archivedReportsIdSet, + report, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, policy, @@ -567,9 +568,9 @@ function IOURequestStepConfirmation({ transactionTaxCode, transactionTaxAmount, customUnitRateID, - backToReport, shouldGenerateTransactionThreadReport, - archivedReportsIdSet, + backToReport, + isViewTourParentReportArchived, ], ); From c09d1691005d8e40815f977dee0df6366ae4b5ce Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 18:25:28 +0530 Subject: [PATCH 14/15] fix tests --- tests/actions/TaskTest.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/actions/TaskTest.ts b/tests/actions/TaskTest.ts index 88198f21fde4a..115d50462eaf3 100644 --- a/tests/actions/TaskTest.ts +++ b/tests/actions/TaskTest.ts @@ -296,13 +296,8 @@ describe('actions/Task', () => { it('Return not empty object', () => { expect(Object.values(getFinishOnboardingTaskOnyxData('setupCategories', false)).length).toBeGreaterThan(0); }); - it('Return empty object', async () => { - const reportNameValuePairs = { - private_isArchived: DateUtils.getDBTime(), - }; - await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${parentReport.reportID}`, reportNameValuePairs); - await waitForBatchedUpdates(); - expect(Object.values(getFinishOnboardingTaskOnyxData('setupCategories', false)).length).toBe(0); + it('Return empty object', () => { + expect(Object.values(getFinishOnboardingTaskOnyxData('setupCategories', true)).length).toBe(0); }); }); From 7a7ca01d9c0c7b3315f3aca61a643b11ded3f43e Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Sep 2025 22:36:54 +0530 Subject: [PATCH 15/15] Rename hook --- src/components/TestDrive/TestDriveDemo.tsx | 4 ++-- ...ask.ts => useIsOnboardingTaskParentReportArchived.ts} | 9 ++++----- src/pages/Search/EmptySearchView.tsx | 4 ++-- .../home/sidebar/FloatingActionButtonAndPopover.tsx | 4 ++-- .../iou/request/step/IOURequestStepConfirmation.tsx | 4 ++-- src/pages/workspace/categories/CategorySettingsPage.tsx | 4 ++-- src/pages/workspace/categories/CreateCategoryPage.tsx | 4 ++-- .../workspace/categories/WorkspaceCategoriesPage.tsx | 4 ++-- 8 files changed, 18 insertions(+), 19 deletions(-) rename src/hooks/{useOnboardingTask.ts => useIsOnboardingTaskParentReportArchived.ts} (57%) diff --git a/src/components/TestDrive/TestDriveDemo.tsx b/src/components/TestDrive/TestDriveDemo.tsx index 4e9ed3f781448..efbf2fd0b1cb5 100644 --- a/src/components/TestDrive/TestDriveDemo.tsx +++ b/src/components/TestDrive/TestDriveDemo.tsx @@ -5,8 +5,8 @@ import EmbeddedDemo from '@components/EmbeddedDemo'; import Modal from '@components/Modal'; import SafeAreaConsumer from '@components/SafeAreaConsumer'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; +import useIsOnboardingTaskParentReportArchived from '@hooks/useIsOnboardingTaskParentReportArchived'; import useOnboardingMessages from '@hooks/useOnboardingMessages'; -import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -28,7 +28,7 @@ function TestDriveDemo() { const [onboardingReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${onboarding?.chatReportID}`, {canBeMissing: true}); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); - const {isParentReportArchived: isViewTourParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const isViewTourParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const {testDrive} = useOnboardingMessages(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); diff --git a/src/hooks/useOnboardingTask.ts b/src/hooks/useIsOnboardingTaskParentReportArchived.ts similarity index 57% rename from src/hooks/useOnboardingTask.ts rename to src/hooks/useIsOnboardingTaskParentReportArchived.ts index f4cd2404fa234..1aa63f985b8a3 100644 --- a/src/hooks/useOnboardingTask.ts +++ b/src/hooks/useIsOnboardingTaskParentReportArchived.ts @@ -1,16 +1,15 @@ -import {isArchivedReport} from '@libs/ReportUtils'; import ONYXKEYS from '@src/ONYXKEYS'; import type {IntroSelectedTask} from '@src/types/onyx/IntroSelected'; import useOnyx from './useOnyx'; +import useReportIsArchived from './useReportIsArchived'; -function useOnboardingTask(taskName: IntroSelectedTask) { +function useIsOnboardingTaskParentReportArchived(taskName: IntroSelectedTask) { const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); const taskReportID = introSelected?.[taskName]; const [taskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, {canBeMissing: true}, [taskReportID]); const [taskParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReport?.parentReportID}`, {canBeMissing: true}); - const [taskParentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${taskParentReport?.reportID}`, {canBeMissing: true}); - return {isParentReportArchived: isArchivedReport(taskParentReportNameValuePairs)}; + return useReportIsArchived(taskParentReport?.reportID); } -export default useOnboardingTask; +export default useIsOnboardingTaskParentReportArchived; diff --git a/src/pages/Search/EmptySearchView.tsx b/src/pages/Search/EmptySearchView.tsx index c16f610c91579..242c8d2bcf89e 100644 --- a/src/pages/Search/EmptySearchView.tsx +++ b/src/pages/Search/EmptySearchView.tsx @@ -20,8 +20,8 @@ import SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton'; import Text from '@components/Text'; import TextLink from '@components/TextLink'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; +import useIsOnboardingTaskParentReportArchived from '@hooks/useIsOnboardingTaskParentReportArchived'; import useLocalize from '@hooks/useLocalize'; -import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import useSearchTypeMenuSections from '@hooks/useSearchTypeMenuSections'; import useStyleUtils from '@hooks/useStyleUtils'; @@ -174,7 +174,7 @@ function EmptySearchViewContent({ }); const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {selector: tryNewDotOnyxSelector, canBeMissing: true}); - const {isParentReportArchived: isViewTourParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const isViewTourParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const shouldRedirectToExpensifyClassic = useMemo(() => { return areAllGroupPoliciesExpenseChatDisabled(allPolicies ?? {}); diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index 9e42cbda744c5..d4ac24d8fc0f4 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -13,9 +13,9 @@ import * as Expensicons from '@components/Icon/Expensicons'; import type {PopoverMenuItem} from '@components/PopoverMenu'; import PopoverMenu from '@components/PopoverMenu'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; +import useIsOnboardingTaskParentReportArchived from '@hooks/useIsOnboardingTaskParentReportArchived'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; -import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import usePermissions from '@hooks/usePermissions'; import usePrevious from '@hooks/usePrevious'; @@ -153,7 +153,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref selector: (policies) => Object.values(policies ?? {}).some((policy) => isPaidGroupPolicy(policy) && isPolicyMember(policy, currentUserPersonalDetails.login)), }); - const {isParentReportArchived: isViewTourParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const isViewTourParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const isReportInSearch = isOnSearchMoneyRequestReportPage(); diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index a5d77a2fce76a..39c0e8b8d4211 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -17,9 +17,9 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' import useDeepCompareRef from '@hooks/useDeepCompareRef'; import useFetchRoute from '@hooks/useFetchRoute'; import useFilesValidation from '@hooks/useFilesValidation'; +import useIsOnboardingTaskParentReportArchived from '@hooks/useIsOnboardingTaskParentReportArchived'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; -import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import useParticipantsInvoiceReport from '@hooks/useParticipantsInvoiceReport'; import usePermissions from '@hooks/usePermissions'; @@ -193,7 +193,7 @@ function IOURequestStepConfirmation({ const isPerDiemRequest = requestType === CONST.IOU.REQUEST_TYPE.PER_DIEM; const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: true}); - const {isParentReportArchived: isViewTourParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); + const isViewTourParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); const [archivedReportsIdSet = new Set()] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { canBeMissing: true, diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index eb926f9ab8992..885103c24db9a 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -12,8 +12,8 @@ import ScrollView from '@components/ScrollView'; import Switch from '@components/Switch'; import Text from '@components/Text'; import useEnvironment from '@hooks/useEnvironment'; +import useIsOnboardingTaskParentReportArchived from '@hooks/useIsOnboardingTaskParentReportArchived'; import useLocalize from '@hooks/useLocalize'; -import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import usePolicy from '@hooks/usePolicy'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -68,7 +68,7 @@ function CategorySettingsPage({ const shouldPreventDisableOrDelete = isDisablingOrDeletingLastEnabledCategory(policy, policyCategories, [policyCategory]); const areCommentsRequired = policyCategory?.areCommentsRequired ?? false; const isQuickSettingsFlow = name === SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORY_SETTINGS; - const {isParentReportArchived: isSetupCategoryTaskParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); + const isSetupCategoryTaskParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); const navigateBack = () => { Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(policyID, backTo) : undefined); diff --git a/src/pages/workspace/categories/CreateCategoryPage.tsx b/src/pages/workspace/categories/CreateCategoryPage.tsx index 9e1e2310e9cb2..0612010e0689d 100644 --- a/src/pages/workspace/categories/CreateCategoryPage.tsx +++ b/src/pages/workspace/categories/CreateCategoryPage.tsx @@ -2,8 +2,8 @@ import React, {useCallback} from 'react'; import type {FormOnyxValues} from '@components/Form/types'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; +import useIsOnboardingTaskParentReportArchived from '@hooks/useIsOnboardingTaskParentReportArchived'; import useLocalize from '@hooks/useLocalize'; -import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; import {createPolicyCategory} from '@libs/actions/Policy/Category'; @@ -27,7 +27,7 @@ function CreateCategoryPage({route}: CreateCategoryPageProps) { const {translate} = useLocalize(); const backTo = route.params?.backTo; const isQuickSettingsFlow = route.name === SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORY_CREATE; - const {isParentReportArchived: isSetupCategoryTaskParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); + const isSetupCategoryTaskParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); const createCategory = useCallback( (values: FormOnyxValues) => { diff --git a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx index 6f5902811dff6..1d5dd94bc772f 100644 --- a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx +++ b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx @@ -26,10 +26,10 @@ import Text from '@components/Text'; import useAutoTurnSelectionModeOffWhenHasNoActiveOption from '@hooks/useAutoTurnSelectionModeOffWhenHasNoActiveOption'; import useCleanupSelectedOptions from '@hooks/useCleanupSelectedOptions'; import useEnvironment from '@hooks/useEnvironment'; +import useIsOnboardingTaskParentReportArchived from '@hooks/useIsOnboardingTaskParentReportArchived'; import useLocalize from '@hooks/useLocalize'; import useMobileSelectionMode from '@hooks/useMobileSelectionMode'; import useNetwork from '@hooks/useNetwork'; -import useOnboardingTask from '@hooks/useOnboardingTask'; import useOnyx from '@hooks/useOnyx'; import usePolicy from '@hooks/usePolicy'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; @@ -92,7 +92,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { const [selectedCategories, setSelectedCategories] = useState([]); const canSelectMultiple = isSmallScreenWidth ? isMobileSelectionModeEnabled : true; - const {isParentReportArchived: isSetupCategoryTaskParentReportArchived} = useOnboardingTask(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); + const isSetupCategoryTaskParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES); const fetchCategories = useCallback(() => { openPolicyCategoriesPage(policyId);