Skip to content
Draft
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
4 changes: 4 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ const DYNAMIC_ROUTES = {
getRoute: (country = '') => `country?country=${country}`,
queryParams: ['country'],
},
WORKSPACE_CATEGORY_EDIT: {
path: 'edit',
entryScreens: [SCREENS.WORKSPACE.CATEGORY_SETTINGS],
},
} as const satisfies DynamicRoutes;

const ROUTES = {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/workspace/categories/CategorySettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from '@libs/CategoryUtils';
import {convertToDisplayString} from '@libs/CurrencyUtils';
import {getLatestErrorMessageField} from '@libs/ErrorUtils';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import {isDisablingOrDeletingLastEnabledCategory} from '@libs/OptionsListUtils';
Expand All @@ -40,7 +41,7 @@ import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import {clearCategoryErrors, deleteWorkspaceCategories, setWorkspaceCategoryEnabled} from '@userActions/Policy/Category';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import SCREENS from '@src/SCREENS';

type CategorySettingsPageProps =
Expand Down Expand Up @@ -212,7 +213,7 @@ function CategorySettingsPage({

const navigateToEditCategory = () => {
Navigation.navigate(
isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORY_EDIT.getRoute(policyID, policyCategory.name, backTo) : ROUTES.WORKSPACE_CATEGORY_EDIT.getRoute(policyID, policyCategory.name),
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@collectioneur I was trying to migrate ROUTES.SETTINGS_CATEGORY_EDIT route as well. But this is opened with isQuickSettingsFlow. The user configures categories and is returned to the expense flow. Do you think we'll be able to migrate it? We don't the exact backTo route.

Copy link
Copy Markdown
Contributor

@collectioneur collectioneur Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! We're currently hitting a slight limitation with dynamic routes on this one. We need the policyID in the dynamic suffix here, but path parameters aren't supported there just yet. The good news is I'm already actively working on adding this logic and should have it wrapped up soon! I'll let you know when it's ready 😄

isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORY_EDIT.getRoute(policyID, policyCategory.name, backTo) : createDynamicRoute(DYNAMIC_ROUTES.WORKSPACE_CATEGORY_EDIT.path),
);
};

Expand Down
19 changes: 6 additions & 13 deletions src/pages/workspace/categories/EditCategoryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useCallback} from 'react';
import type {FormInputErrors, FormOnyxValues} from '@components/Form/types';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import useDynamicBackPath from '@hooks/useDynamicBackPath';
import useLocalize from '@hooks/useLocalize';
import usePolicyData from '@hooks/usePolicyData';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -12,7 +13,7 @@ import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import {renamePolicyCategory} from '@userActions/Policy/Category';
import CONST from '@src/CONST';
import type ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import CategoryForm from './CategoryForm';

Expand All @@ -22,6 +23,7 @@ type EditCategoryPageProps =

function EditCategoryPage({route}: EditCategoryPageProps) {
const {backTo, policyID, categoryName: currentCategoryName} = route.params;
const dynamicBackPath = useDynamicBackPath(DYNAMIC_ROUTES.WORKSPACE_CATEGORY_EDIT.path);
const policyData = usePolicyData(policyID);
const {categories: policyCategories} = policyData;
const styles = useThemeStyles();
Expand Down Expand Up @@ -56,15 +58,10 @@ function EditCategoryPage({route}: EditCategoryPageProps) {

// Ensure Onyx.update is executed before navigation to prevent UI blinking issues, affecting the category name and rate.
Navigation.setNavigationActionToMicrotaskQueue(() => {
Navigation.goBack(
isQuickSettingsFlow
? ROUTES.SETTINGS_CATEGORY_SETTINGS.getRoute(policyID, currentCategoryName, backTo)
: ROUTES.WORKSPACE_CATEGORY_SETTINGS.getRoute(policyID, currentCategoryName),
{compareParams: false},
);
Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORY_SETTINGS.getRoute(policyID, currentCategoryName, backTo) : dynamicBackPath, {compareParams: false});
});
},
[isQuickSettingsFlow, currentCategoryName, policyData, policyID, backTo],
[isQuickSettingsFlow, currentCategoryName, dynamicBackPath, policyData, policyID, backTo],
);

return (
Expand All @@ -82,11 +79,7 @@ function EditCategoryPage({route}: EditCategoryPageProps) {
<HeaderWithBackButton
title={translate('workspace.categories.editCategory')}
onBackButtonPress={() =>
Navigation.goBack(
isQuickSettingsFlow
? ROUTES.SETTINGS_CATEGORY_SETTINGS.getRoute(route.params.policyID, route.params.categoryName, backTo)
: ROUTES.WORKSPACE_CATEGORY_SETTINGS.getRoute(route.params.policyID, route.params.categoryName),
)
Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORY_SETTINGS.getRoute(route.params.policyID, route.params.categoryName, backTo) : dynamicBackPath)
}
/>
<CategoryForm
Expand Down
Loading