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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion src/components/TestDrive/TestDriveDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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 useOnyx from '@hooks/useOnyx';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
Expand All @@ -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 isViewTourParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR);

const {testDrive} = useOnboardingMessages();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const [isCurrentUserPolicyAdmin = false] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {
Expand All @@ -36,7 +40,7 @@ function TestDriveDemo() {
useEffect(() => {
InteractionManager.runAfterInteractions(() => {
setIsVisible(true);
completeTestDriveTask();
completeTestDriveTask(isViewTourParentReportArchived);
});

// This should fire only during mount.
Expand Down
15 changes: 15 additions & 0 deletions src/hooks/useIsOnboardingTaskParentReportArchived.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import ONYXKEYS from '@src/ONYXKEYS';
import type {IntroSelectedTask} from '@src/types/onyx/IntroSelected';
import useOnyx from './useOnyx';
import useReportIsArchived from './useReportIsArchived';

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});

return useReportIsArchived(taskParentReport?.reportID);
}

export default useIsOnboardingTaskParentReportArchived;
14 changes: 8 additions & 6 deletions src/libs/actions/Policy/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@
import type {OnyxData} from '@src/types/onyx/Request';

let allRecentlyUsedCategories: OnyxCollection<RecentlyUsedCategories> = {};
Onyx.connect({

Check warning on line 42 in src/libs/actions/Policy/Category.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES,
waitForCollectionCallback: true,
callback: (val) => (allRecentlyUsedCategories = val),
});

let allPolicyCategories: OnyxCollection<PolicyCategories> = {};
Onyx.connect({

Check warning on line 49 in src/libs/actions/Policy/Category.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_CATEGORIES,
waitForCollectionCallback: true,
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 ?? []));
Expand Down Expand Up @@ -329,6 +329,7 @@
function setWorkspaceCategoryEnabled(
policyID: string,
categoriesToUpdate: Record<string, {name: string; enabled: boolean}>,
isSetupCategoriesTaskParentReportArchived: boolean,
policyTagLists: PolicyTagLists = {},
allTransactionViolations: OnyxCollection<TransactionViolations> = {},
) {
Expand Down Expand Up @@ -398,7 +399,7 @@
};

pushTransactionViolationsOnyxData(onyxData, policyID, policyTagLists, policyCategories, allTransactionViolations, {}, optimisticPolicyCategoriesData);
appendSetupCategoriesOnboardingData(onyxData);
appendSetupCategoriesOnboardingData(onyxData, isSetupCategoriesTaskParentReportArchived);

const parameters = {
policyID,
Expand Down Expand Up @@ -598,9 +599,9 @@
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}]),
Expand Down Expand Up @@ -978,6 +979,7 @@
function deleteWorkspaceCategories(
policyID: string,
categoryNamesToDelete: string[],
isSetupCategoriesTaskParentReportArchived: boolean,
policyTagLists: PolicyTagLists = {},
transactionViolations: OnyxCollection<TransactionViolations> = {},
) {
Expand Down Expand Up @@ -1027,7 +1029,7 @@

const optimisticPolicyData: Partial<Policy> = shouldDisableRequiresCategory ? {requiresCategory: false} : {};
pushTransactionViolationsOnyxData(onyxData, policyID, policyTagLists, policyCategories, transactionViolations, optimisticPolicyData, optimisticPolicyCategoriesData);
appendSetupCategoriesOnboardingData(onyxData);
appendSetupCategoriesOnboardingData(onyxData, isSetupCategoriesTaskParentReportArchived);

const parameters = {
policyID,
Expand Down
20 changes: 3 additions & 17 deletions src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
let currentUserEmail = '';
let currentUserAccountID = -1;

Onyx.connect({

Check warning on line 50 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -56,13 +56,13 @@
});

let allPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>;
Onyx.connect({

Check warning on line 59 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => (allPersonalDetails = value),
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 65 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -75,7 +75,7 @@
});

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

Check warning on line 78 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -84,23 +84,11 @@
});

let introSelected: OnyxEntry<OnyxTypes.IntroSelected> = {};
Onyx.connect({

Check warning on line 87 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_INTRO_SELECTED,
callback: (val) => (introSelected = val),
});

let allReportNameValuePair: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
if (!value) {
return;
}
allReportNameValuePair = value;
},
});

/**
* Clears out the task info from the store
*/
Expand Down Expand Up @@ -1312,12 +1300,10 @@
});
}

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) {
Expand All @@ -1328,9 +1314,9 @@

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 {
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Tour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function startTestDrive(
shouldUpdateSelfTourViewedOnlyLocally: boolean,
hasUserBeenAddedToNudgeMigration: boolean,
isUserPaidPolicyMember: boolean,
isViewTourTaskParentReportArchived: boolean,
) {
InteractionManager.runAfterInteractions(() => {
if (
Expand All @@ -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);
Expand Down
12 changes: 8 additions & 4 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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 useOnyx from '@hooks/useOnyx';
import useSearchTypeMenuSections from '@hooks/useSearchTypeMenuSections';
Expand Down Expand Up @@ -173,6 +174,8 @@ function EmptySearchViewContent({
});
const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {selector: tryNewDotOnyxSelector, canBeMissing: true});

const isViewTourParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR);

const shouldRedirectToExpensifyClassic = useMemo(() => {
return areAllGroupPoliciesExpenseChatDisabled(allPolicies ?? {});
}, [allPolicies]);
Expand Down Expand Up @@ -269,7 +272,7 @@ function EmptySearchViewContent({
}

const startTestDriveAction = () => {
startTestDrive(introSelected, false, tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember);
startTestDrive(introSelected, false, tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember, isViewTourParentReportArchived);
};

// If we are grouping by reports, show a custom message rather than a type-specific message
Expand Down Expand Up @@ -439,6 +442,9 @@ function EmptySearchViewContent({
styles.textAlignLeft,
styles.tripEmptyStateLottieWebView,
introSelected,
tryNewDot?.hasBeenAddedToNudgeMigration,
isUserPaidPolicyMember,
isViewTourParentReportArchived,
hasResults,
defaultViewItemHeader,
hasSeenTour,
Expand All @@ -447,10 +453,8 @@ function EmptySearchViewContent({
activePolicyID,
currentUserPersonalDetails,
tripViewChildren,
shouldRedirectToExpensifyClassic,
hasTransactions,
tryNewDot?.hasBeenAddedToNudgeMigration,
isUserPaidPolicyMember,
shouldRedirectToExpensifyClassic,
]);

return (
Expand Down
7 changes: 6 additions & 1 deletion src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 useOnyx from '@hooks/useOnyx';
Expand Down Expand Up @@ -152,6 +153,8 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref
selector: (policies) => Object.values(policies ?? {}).some((policy) => isPaidGroupPolicy(policy) && isPolicyMember(policy, currentUserPersonalDetails.login)),
});

const isViewTourParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR);

const isReportInSearch = isOnSearchMoneyRequestReportPage();

const groupPoliciesWithChatEnabled = getGroupPaidPoliciesWithExpenseChatEnabled();
Expand Down Expand Up @@ -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, isViewTourParentReportArchived),
),
},
]
: []),
Expand Down
12 changes: 8 additions & 4 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ 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 useOnyx from '@hooks/useOnyx';
Expand Down Expand Up @@ -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 isViewTourParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR);

const [archivedReportsIdSet = new Set<string>()] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, {
canBeMissing: true,
selector: (all): ArchivedReportsIDSet => {
Expand Down Expand Up @@ -500,7 +503,7 @@ function IOURequestStepConfirmation({
!!item.linkedTrackedExpenseReportID && archivedReportsIdSet.has(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${item.linkedTrackedExpenseReportID}`);

if (isTestDriveReceipt) {
completeTestDriveTask();
completeTestDriveTask(isViewTourParentReportArchived);
}

requestMoneyIOUActions({
Expand Down Expand Up @@ -552,9 +555,10 @@ function IOURequestStepConfirmation({
});
},
[
report,
transactions,
receiptFiles,
archivedReportsIdSet,
report,
currentUserPersonalDetails.login,
currentUserPersonalDetails.accountID,
policy,
Expand All @@ -564,9 +568,9 @@ function IOURequestStepConfirmation({
transactionTaxCode,
transactionTaxAmount,
customUnitRateID,
backToReport,
shouldGenerateTransactionThreadReport,
archivedReportsIdSet,
backToReport,
isViewTourParentReportArchived,
],
);

Expand Down
12 changes: 10 additions & 2 deletions src/pages/workspace/categories/CategorySettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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 useOnyx from '@hooks/useOnyx';
import usePolicy from '@hooks/usePolicy';
Expand Down Expand Up @@ -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 isSetupCategoryTaskParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES);

const navigateBack = () => {
Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(policyID, backTo) : undefined);
Expand Down Expand Up @@ -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}},
isSetupCategoryTaskParentReportArchived,
policyTagLists,
allTransactionViolations,
);
};

const navigateToEditCategory = () => {
Expand All @@ -139,7 +147,7 @@ function CategorySettingsPage({
};

const deleteCategory = () => {
deleteWorkspaceCategories(policyID, [categoryName], policyTagLists, allTransactionViolations);
deleteWorkspaceCategories(policyID, [categoryName], isSetupCategoryTaskParentReportArchived, policyTagLists, allTransactionViolations);
setDeleteCategoryConfirmModalVisible(false);
navigateBack();
};
Expand Down
6 changes: 4 additions & 2 deletions src/pages/workspace/categories/CreateCategoryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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 useOnyx from '@hooks/useOnyx';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -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 isSetupCategoryTaskParentReportArchived = useIsOnboardingTaskParentReportArchived(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES);

const createCategory = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_CATEGORY_FORM>) => {
createPolicyCategory(route.params.policyID, values.categoryName.trim());
createPolicyCategory(route.params.policyID, values.categoryName.trim(), isSetupCategoryTaskParentReportArchived);
Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(route.params.policyID, backTo) : undefined);
},
[isQuickSettingsFlow, route.params.policyID, backTo],
[route.params.policyID, isSetupCategoryTaskParentReportArchived, isQuickSettingsFlow, backTo],
);

return (
Expand Down
Loading
Loading