From c38cbcbb548e0ace824608e2678b1351e6c565a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Musia=C5=82?= Date: Thu, 23 Apr 2026 11:29:02 +0200 Subject: [PATCH 1/8] Migrate CategorySelectorModal to be nv RHP --- src/ROUTES.ts | 16 +++++ src/SCREENS.ts | 3 + .../CategorySelectorModal.tsx | 64 ------------------- src/components/CategorySelector/index.tsx | 63 ++++++------------ .../ModalStackNavigators/index.tsx | 3 + .../RELATIONS/WORKSPACE_TO_RHP.ts | 3 + src/libs/Navigation/linkingConfig/config.ts | 5 ++ src/libs/Navigation/types.ts | 12 ++++ .../DynamicDefaultCategorySelectorPage.tsx | 59 +++++++++++++++++ .../DynamicSpendCategorySelectorPage.tsx | 61 ++++++++++++++++++ .../WorkspaceCategoriesSettingsPage.tsx | 45 +++---------- .../PolicyDistanceRatesSettingsPage.tsx | 21 +----- .../perDiem/WorkspacePerDiemSettingsPage.tsx | 21 +----- 13 files changed, 198 insertions(+), 178 deletions(-) delete mode 100644 src/components/CategorySelector/CategorySelectorModal.tsx create mode 100644 src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx create mode 100644 src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index c4ef0dc68eef..b719cbad629d 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -293,6 +293,16 @@ const DYNAMIC_ROUTES = { path: 'imported', entryScreens: [SCREENS.WORKSPACE.CATEGORIES], }, + SPEND_CATEGORY_SELECTOR: { + path: 'spend-category-selector/:groupID', + entryScreens: [SCREENS.WORKSPACE.CATEGORIES_SETTINGS], + getRoute: (groupID: string) => `spend-category-selector/${groupID}` as const, + }, + DEFAULT_CATEGORY_SELECTOR: { + path: 'default-category-selector/:customUnitID', + entryScreens: [SCREENS.WORKSPACE.DISTANCE_RATES_SETTINGS, SCREENS.WORKSPACE.PER_DIEM_SETTINGS], + getRoute: (customUnitID: string) => `default-category-selector/${customUnitID}` as const, + }, WORKSPACE_INVITE: { path: 'invite', entryScreens: [SCREENS.WORKSPACE.PROFILE, SCREENS.WORKSPACE.MEMBERS], @@ -1517,6 +1527,12 @@ const ROUTES = { // eslint-disable-next-line no-restricted-syntax -- Legacy route generation getRoute: (policyID: string, backTo = '') => getUrlWithBackToParam(`settings/${policyID}/categories/new`, backTo), }, + SETTINGS_SPEND_CATEGORY_SELECTOR: { + route: 'settings/:policyID/categories/spend-category-selector/:groupID', + getRoute: (policyID: string, groupID: string, backTo = '') => + // eslint-disable-next-line no-restricted-syntax -- Legacy route generation + getUrlWithBackToParam(`settings/${policyID}/categories/spend-category-selector/${groupID}` as const, backTo), + }, SETTINGS_CATEGORIES_IMPORT: { route: 'settings/:policyID/categories/import', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index bf3e7f65f2a4..a1dbf19d1dcb 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -429,6 +429,7 @@ const SCREENS = { SETTINGS_CATEGORIES_SETTINGS: 'Settings_Categories_Settings', SETTINGS_CATEGORY_CREATE: 'Settings_Category_Create', DYNAMIC_SETTINGS_CATEGORY_EDIT: 'Dynamic_Settings_Category_Edit', + SETTINGS_SPEND_CATEGORY_SELECTOR: 'Settings_Spend_Category_Selector', SETTINGS_CATEGORIES_ROOT: 'Settings_Categories', SETTINGS_CATEGORIES_IMPORT: 'Settings_Categories_Import', SETTINGS_CATEGORIES_IMPORTED: 'Settings_Categories_Imported', @@ -784,6 +785,8 @@ const SCREENS = { CATEGORIES_SETTINGS: 'Categories_Settings', DYNAMIC_CATEGORIES_IMPORT: 'Dynamic_Categories_Import', DYNAMIC_CATEGORIES_IMPORTED: 'Dynamic_Categories_Imported', + DYNAMIC_SPEND_CATEGORY_SELECTOR: 'Dynamic_Spend_Category_Selector', + DYNAMIC_DEFAULT_CATEGORY_SELECTOR: 'Dynamic_Default_Category_Selector', MORE_FEATURES: 'Workspace_More_Features', MEMBER_DETAILS: 'Workspace_Member_Details', MEMBER_DETAILS_ROLE: 'Workspace_Member_Details_Role', diff --git a/src/components/CategorySelector/CategorySelectorModal.tsx b/src/components/CategorySelector/CategorySelectorModal.tsx deleted file mode 100644 index c44295a773b3..000000000000 --- a/src/components/CategorySelector/CategorySelectorModal.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import React from 'react'; -import CategoryPicker from '@components/CategoryPicker'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import Modal from '@components/Modal'; -import ScreenWrapper from '@components/ScreenWrapper'; -import type {ListItem} from '@components/SelectionList/types'; -import useThemeStyles from '@hooks/useThemeStyles'; -import CONST from '@src/CONST'; - -type CategorySelectorModalProps = { - /** The ID of the associated policy */ - policyID: string; - - /** Whether the modal is visible */ - isVisible: boolean; - - /** Selected category */ - currentCategory: string; - - /** Function to call when the user selects a category */ - onCategorySelected: (value: ListItem) => void; - - /** Function to call when the user closes the category selector modal */ - onClose: () => void; - - /** Label to display on field */ - label: string; -}; - -function CategorySelectorModal({policyID, isVisible, currentCategory, onCategorySelected, onClose, label}: CategorySelectorModalProps) { - const styles = useThemeStyles(); - - return ( - - - - - - - ); -} - -export default CategorySelectorModal; diff --git a/src/components/CategorySelector/index.tsx b/src/components/CategorySelector/index.tsx index 55c7d563dbc5..7448435963a3 100644 --- a/src/components/CategorySelector/index.tsx +++ b/src/components/CategorySelector/index.tsx @@ -1,20 +1,14 @@ import React from 'react'; import type {StyleProp, ViewStyle} from 'react-native'; -import {View} from 'react-native'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; -import type {ListItem} from '@components/SelectionList/types'; import useThemeStyles from '@hooks/useThemeStyles'; import {getDecodedCategoryName} from '@libs/CategoryUtils'; +import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute'; +import Navigation from '@libs/Navigation/Navigation'; import CONST from '@src/CONST'; -import CategorySelectorModal from './CategorySelectorModal'; +import {DYNAMIC_ROUTES} from '@src/ROUTES'; type CategorySelectorProps = { - /** The ID of the associated policy */ - policyID: string; - - /** Function to call when the user selects a category */ - setNewCategory: (value: ListItem) => void; - /** Currently selected category */ defaultValue?: string; @@ -27,48 +21,31 @@ type CategorySelectorProps = { /** Whether item is focused or active */ focused?: boolean; - /** Whether category item picker is visible */ - isPickerVisible: boolean; - - /** Callback to show category picker */ - showPickerModal: () => void; - - /** Callback to hide category picker */ - hidePickerModal: () => void; + /** The custom unit ID to update when selecting a category */ + customUnitID: string; }; -function CategorySelector({defaultValue = '', wrapperStyle, label, setNewCategory, policyID, focused, isPickerVisible, showPickerModal, hidePickerModal}: CategorySelectorProps) { +function CategorySelector({defaultValue = '', wrapperStyle, label, focused, customUnitID}: CategorySelectorProps) { const styles = useThemeStyles(); - const updateCategoryInput = (categoryItem: ListItem) => { - setNewCategory(categoryItem); - hidePickerModal(); - }; - const decodedCategoryName = getDecodedCategoryName(defaultValue); const descStyle = decodedCategoryName.length === 0 ? styles.textNormal : null; + const onPress = () => { + Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.DEFAULT_CATEGORY_SELECTOR.getRoute(customUnitID))); + }; + return ( - - - - + ); } diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index f8cdc55bd835..3defbe8ed3af 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -315,6 +315,7 @@ const CategoriesModalStackNavigator = createModalStackNavigator({ [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_SETTINGS]: () => require('../../../../pages/workspace/categories/WorkspaceCategoriesSettingsPage').default, [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORY_CREATE]: () => require('../../../../pages/workspace/categories/CreateCategoryPage').default, [SCREENS.SETTINGS_CATEGORIES.DYNAMIC_SETTINGS_CATEGORY_EDIT]: () => require('../../../../pages/workspace/categories/EditCategoryPage').default, + [SCREENS.SETTINGS_CATEGORIES.SETTINGS_SPEND_CATEGORY_SELECTOR]: () => require('../../../../pages/workspace/categories/DynamicSpendCategorySelectorPage').default, [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORY_SETTINGS]: () => require('../../../../pages/workspace/categories/CategorySettingsPage').default, [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_IMPORT]: () => require('../../../../pages/workspace/categories/ImportCategoriesPage').default, [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_IMPORTED]: () => require('../../../../pages/workspace/categories/ImportedCategoriesPage').default, @@ -524,6 +525,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/categories/WorkspaceCategoriesSettingsPage').default, [SCREENS.WORKSPACE.DYNAMIC_CATEGORIES_IMPORT]: () => require('../../../../pages/workspace/categories/ImportCategoriesPage').default, [SCREENS.WORKSPACE.DYNAMIC_CATEGORIES_IMPORTED]: () => require('../../../../pages/workspace/categories/ImportedCategoriesPage').default, + [SCREENS.WORKSPACE.DYNAMIC_SPEND_CATEGORY_SELECTOR]: () => require('../../../../pages/workspace/categories/DynamicSpendCategorySelectorPage').default, + [SCREENS.WORKSPACE.DYNAMIC_DEFAULT_CATEGORY_SELECTOR]: () => require('../../../../pages/workspace/categories/DynamicDefaultCategorySelectorPage').default, [SCREENS.WORKSPACE.UPGRADE]: () => require('../../../../pages/workspace/upgrade/WorkspaceUpgradePage').default, [SCREENS.WORKSPACE.DOWNGRADE]: () => require('../../../../pages/workspace/downgrade/WorkspaceDowngradePage').default, [SCREENS.WORKSPACE.PAY_AND_DOWNGRADE]: () => require('../../../../pages/workspace/downgrade/PayAndDowngradePage').default, diff --git a/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts b/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts index 10e6056c9dfa..d868c1697aab 100755 --- a/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts +++ b/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts @@ -211,6 +211,7 @@ const WORKSPACE_TO_RHP: Partial['config'] = { }, [SCREENS.WORKSPACE.DYNAMIC_CATEGORIES_IMPORT]: DYNAMIC_ROUTES.WORKSPACE_CATEGORIES_IMPORT.path, [SCREENS.WORKSPACE.DYNAMIC_CATEGORIES_IMPORTED]: DYNAMIC_ROUTES.WORKSPACE_CATEGORIES_IMPORTED.path, + [SCREENS.WORKSPACE.DYNAMIC_SPEND_CATEGORY_SELECTOR]: DYNAMIC_ROUTES.SPEND_CATEGORY_SELECTOR.path, + [SCREENS.WORKSPACE.DYNAMIC_DEFAULT_CATEGORY_SELECTOR]: DYNAMIC_ROUTES.DEFAULT_CATEGORY_SELECTOR.path, [SCREENS.WORKSPACE.WORKFLOWS_PAYER]: { path: ROUTES.WORKSPACE_WORKFLOWS_PAYER.route, }, @@ -1478,6 +1480,9 @@ const config: LinkingOptions['config'] = { path: ROUTES.SETTINGS_CATEGORY_CREATE.route, }, [SCREENS.SETTINGS_CATEGORIES.DYNAMIC_SETTINGS_CATEGORY_EDIT]: DYNAMIC_ROUTES.SETTINGS_CATEGORY_EDIT.path, + [SCREENS.SETTINGS_CATEGORIES.SETTINGS_SPEND_CATEGORY_SELECTOR]: { + path: ROUTES.SETTINGS_SPEND_CATEGORY_SELECTOR.route, + }, [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_IMPORT]: { path: ROUTES.SETTINGS_CATEGORIES_IMPORT.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 855bfdad713d..91ea19806c9e 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -438,6 +438,18 @@ type SettingsNavigatorParamList = { // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md backTo?: Routes; }; + [SCREENS.WORKSPACE.DYNAMIC_SPEND_CATEGORY_SELECTOR]: { + policyID: string; + groupID: string; + }; + [SCREENS.SETTINGS_CATEGORIES.SETTINGS_SPEND_CATEGORY_SELECTOR]: { + policyID: string; + groupID: string; + }; + [SCREENS.WORKSPACE.DYNAMIC_DEFAULT_CATEGORY_SELECTOR]: { + policyID: string; + customUnitID: string; + }; [SCREENS.WORKSPACE.DYNAMIC_CATEGORIES_IMPORT]: { policyID: string; }; diff --git a/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx b/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx new file mode 100644 index 000000000000..e57e9582de62 --- /dev/null +++ b/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx @@ -0,0 +1,59 @@ +import React from 'react'; +import CategoryPicker from '@components/CategoryPicker'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import type {ListItem} from '@components/SelectionList/types'; +import useDynamicBackPath from '@hooks/useDynamicBackPath'; +import useLocalize from '@hooks/useLocalize'; +import useOnyx from '@hooks/useOnyx'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; +import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; +import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; +import {setPolicyCustomUnitDefaultCategory} from '@userActions/Policy/Category'; +import ONYXKEYS from '@src/ONYXKEYS'; +import {DYNAMIC_ROUTES} from '@src/ROUTES'; +import type SCREENS from '@src/SCREENS'; + +type DynamicDefaultCategorySelectorPageProps = PlatformStackScreenProps; + +function DynamicDefaultCategorySelectorPage({route}: DynamicDefaultCategorySelectorPageProps) { + const {policyID, customUnitID} = route.params; + const styles = useThemeStyles(); + const {translate} = useLocalize(); + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); + const currentCategory = policy?.customUnits?.[customUnitID]?.defaultCategory ?? ''; + const backPath = useDynamicBackPath(DYNAMIC_ROUTES.DEFAULT_CATEGORY_SELECTOR.path); + + const onCategorySelected = (selectedCategory: ListItem) => { + if (!selectedCategory.searchText || currentCategory === selectedCategory.searchText) { + return; + } + setPolicyCustomUnitDefaultCategory(policyID, customUnitID, currentCategory, selectedCategory.searchText); + Navigation.goBack(backPath); + }; + + return ( + + Navigation.goBack(backPath)} + /> + + + ); +} + +export default DynamicDefaultCategorySelectorPage; diff --git a/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx b/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx new file mode 100644 index 000000000000..44666e9bf9a9 --- /dev/null +++ b/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx @@ -0,0 +1,61 @@ +import React from 'react'; +import CategoryPicker from '@components/CategoryPicker'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import type {ListItem} from '@components/SelectionList/types'; +import useDynamicBackPath from '@hooks/useDynamicBackPath'; +import useOnyx from '@hooks/useOnyx'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; +import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; +import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; +import {setWorkspaceDefaultSpendCategory} from '@userActions/Policy/Policy'; +import ONYXKEYS from '@src/ONYXKEYS'; +import {DYNAMIC_ROUTES} from '@src/ROUTES'; +import type SCREENS from '@src/SCREENS'; + +type DynamicSpendCategorySelectorPageProps = + | PlatformStackScreenProps + | PlatformStackScreenProps; + +function DynamicSpendCategorySelectorPage({route}: DynamicSpendCategorySelectorPageProps) { + const {policyID, groupID} = route.params; + const styles = useThemeStyles(); + const backPath = useDynamicBackPath(DYNAMIC_ROUTES.SPEND_CATEGORY_SELECTOR.path); + + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); + const label = groupID.charAt(0).toUpperCase() + groupID.slice(1); + const currentCategory = policy?.mccGroup?.[groupID]?.category ?? ''; + + const onCategorySelected = (selectedCategory: ListItem) => { + if (!selectedCategory.keyForList || currentCategory === selectedCategory.keyForList) { + return; + } + setWorkspaceDefaultSpendCategory(policyID, groupID, selectedCategory.keyForList, policy?.mccGroup); + Navigation.goBack(backPath); + }; + + return ( + + Navigation.goBack(backPath)} + /> + + + ); +} + +export default DynamicSpendCategorySelectorPage; diff --git a/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx b/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx index 15332777af63..83c82515891d 100644 --- a/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx +++ b/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx @@ -1,6 +1,5 @@ -import React, {useCallback, useMemo, useState} from 'react'; +import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; -import CategorySelectorModal from '@components/CategorySelector/CategorySelectorModal'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; @@ -11,6 +10,7 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import usePolicyData from '@hooks/usePolicyData'; import useThemeStyles from '@hooks/useThemeStyles'; +import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; @@ -21,11 +21,10 @@ import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnec import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import {setWorkspaceRequiresCategory} from '@userActions/Policy/Category'; -import {clearPolicyErrorField, setWorkspaceDefaultSpendCategory} from '@userActions/Policy/Policy'; +import {clearPolicyErrorField} from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; -import ROUTES from '@src/ROUTES'; +import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; -import KeyboardUtils from '@src/utils/keyboard'; type WorkspaceCategoriesSettingsPageProps = WithPolicyConnectionsProps & ( @@ -40,9 +39,6 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet const policyData = usePolicyData(policyID); const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0; const currentConnectionName = getCurrentConnectionName(policy); - const [isSelectorModalVisible, setIsSelectorModalVisible] = useState(false); - const [categoryID, setCategoryID] = useState(); - const [groupID, setGroupID] = useState(); const isQuickSettingsFlow = route.name === SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_SETTINGS; const toggleSubtitle = isConnectedToAccounting && currentConnectionName ? translate('workspace.categories.needCategoryForExportToIntegration', currentConnectionName) : undefined; @@ -72,27 +68,16 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet const hasEnabledCategories = hasEnabledOptions(policyData.categories); const isToggleDisabled = !policy?.areCategoriesEnabled || !hasEnabledCategories || isConnectedToAccounting; - const setNewCategory = (selectedCategory: ListItem, currentGroupID: string) => { - if (!selectedCategory.keyForList) { - return; - } - if (categoryID !== selectedCategory.keyForList) { - setWorkspaceDefaultSpendCategory(policyID, currentGroupID, selectedCategory.keyForList, policy?.mccGroup); - } - - KeyboardUtils.dismiss({ - afterTransition: () => setIsSelectorModalVisible(false), - }); - }; - const onSelectItem = (item: ListItem) => { - if (!item.groupID || !item.categoryID) { + if (!item.groupID) { return; } - setIsSelectorModalVisible(true); - setCategoryID(item.categoryID); - setGroupID(item.groupID); + Navigation.navigate( + isQuickSettingsFlow + ? ROUTES.SETTINGS_SPEND_CATEGORY_SELECTOR.getRoute(policyID, item.groupID, backTo) + : createDynamicRoute(DYNAMIC_ROUTES.SPEND_CATEGORY_SELECTOR.getRoute(item.groupID)), + ); }; const selectionListHeaderContent = ( @@ -149,16 +134,6 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet )} - {!!categoryID && !!groupID && ( - setIsSelectorModalVisible(false)} - onCategorySelected={(selectedCategory) => setNewCategory(selectedCategory, groupID)} - label={groupID[0].toUpperCase() + groupID.slice(1)} - /> - )} ); diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx index 755f2dd5b9c9..2059b5df6367 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx @@ -1,4 +1,4 @@ -import React, {useState} from 'react'; +import React from 'react'; import {View} from 'react-native'; import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; import CategorySelector from '@components/CategorySelector'; @@ -7,7 +7,6 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RenderHTML from '@components/RenderHTML'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; -import type {ListItem} from '@components/SelectionList/types'; import Switch from '@components/Switch'; import Text from '@components/Text'; import type {UnitItemType} from '@components/UnitPicker'; @@ -21,7 +20,6 @@ import {hasEnabledOptions} from '@libs/OptionsListUtils'; import {getDistanceRateCustomUnit} from '@libs/PolicyUtils'; import type {SettingsNavigatorParamList} from '@navigation/types'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; -import {setPolicyCustomUnitDefaultCategory} from '@userActions/Policy/Category'; import {clearPolicyDistanceRatesErrorFields, setPolicyDistanceRatesUnit} from '@userActions/Policy/DistanceRate'; import {enableDistanceRequestTax} from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; @@ -39,7 +37,6 @@ function PolicyDistanceRatesSettingsPage({route}: PolicyDistanceRatesSettingsPag const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`); const styles = useThemeStyles(); - const [isCategoryPickerVisible, setIsCategoryPickerVisible] = useState(false); const {translate} = useLocalize(); const customUnit = getDistanceRateCustomUnit(policy); const isDistanceTrackTaxEnabled = !!customUnit?.attributes?.taxEnabled; @@ -59,14 +56,6 @@ function PolicyDistanceRatesSettingsPage({route}: PolicyDistanceRatesSettingsPag setPolicyDistanceRatesUnit(policyID, customUnit, {...customUnit, attributes}); }; - const setNewCategory = (category: ListItem) => { - if (!category.searchText || !customUnit || defaultCategory === category.searchText) { - return; - } - - setPolicyCustomUnitDefaultCategory(policyID, customUnit.customUnitID, customUnit.defaultCategory, category.searchText); - }; - const clearErrorFields = (fieldName: keyof CustomUnit) => { if (!customUnit?.customUnitID) { return; @@ -117,7 +106,7 @@ function PolicyDistanceRatesSettingsPage({route}: PolicyDistanceRatesSettingsPag /> )} - {!!policy?.areCategoriesEnabled && hasEnabledOptions(policyCategories ?? {}) && ( + {!!policy?.areCategoriesEnabled && hasEnabledOptions(policyCategories ?? {}) && !!customUnit?.customUnitID && ( clearErrorFields('defaultCategory')} > setIsCategoryPickerVisible(true)} - hidePickerModal={() => setIsCategoryPickerVisible(false)} + customUnitID={customUnit.customUnitID} /> )} diff --git a/src/pages/workspace/perDiem/WorkspacePerDiemSettingsPage.tsx b/src/pages/workspace/perDiem/WorkspacePerDiemSettingsPage.tsx index 220f6ff9fd46..42cda962f1dd 100644 --- a/src/pages/workspace/perDiem/WorkspacePerDiemSettingsPage.tsx +++ b/src/pages/workspace/perDiem/WorkspacePerDiemSettingsPage.tsx @@ -1,4 +1,4 @@ -import React, {useState} from 'react'; +import React from 'react'; import {View} from 'react-native'; import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; import CategorySelector from '@components/CategorySelector'; @@ -6,7 +6,6 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; -import type {ListItem} from '@components/SelectionList/types'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -17,7 +16,6 @@ import {hasEnabledOptions} from '@libs/OptionsListUtils'; import {getPerDiemCustomUnit} from '@libs/PolicyUtils'; import type {SettingsNavigatorParamList} from '@navigation/types'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; -import {setPolicyCustomUnitDefaultCategory} from '@userActions/Policy/Category'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type SCREENS from '@src/SCREENS'; @@ -31,7 +29,6 @@ function WorkspacePerDiemSettingsPage({route}: WorkspacePerDiemSettingsPageProps const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`); const styles = useThemeStyles(); - const [isCategoryPickerVisible, setIsCategoryPickerVisible] = useState(false); const {translate} = useLocalize(); const customUnit = getPerDiemCustomUnit(policy); const customUnitID = customUnit?.customUnitID; @@ -41,14 +38,6 @@ function WorkspacePerDiemSettingsPage({route}: WorkspacePerDiemSettingsPageProps const FullPageBlockingView = !customUnit ? FullPageOfflineBlockingView : View; - const setNewCategory = (category: ListItem) => { - if (!category.searchText || !customUnit || defaultCategory === category.searchText || !customUnitID) { - return; - } - - setPolicyCustomUnitDefaultCategory(policyID, customUnitID, customUnit.defaultCategory, category.searchText); - }; - const clearErrorFields = (fieldName: keyof CustomUnit) => { if (!customUnitID) { return; @@ -77,7 +66,7 @@ function WorkspacePerDiemSettingsPage({route}: WorkspacePerDiemSettingsPageProps contentContainerStyle={styles.flexGrow1} keyboardShouldPersistTaps="always" > - {!!policy?.areCategoriesEnabled && hasEnabledOptions(policyCategories ?? {}) && ( + {!!policy?.areCategoriesEnabled && hasEnabledOptions(policyCategories ?? {}) && !!customUnitID && ( clearErrorFields('defaultCategory')} > setIsCategoryPickerVisible(true)} - hidePickerModal={() => setIsCategoryPickerVisible(false)} + customUnitID={customUnitID} /> )} From 93b33f2be87ad3baac74e3eff26e8a60d6fda25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Musia=C5=82?= Date: Thu, 23 Apr 2026 12:27:03 +0200 Subject: [PATCH 2/8] Remove old linking config --- src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts b/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts index d868c1697aab..d1af804331c3 100755 --- a/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts +++ b/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts @@ -221,7 +221,6 @@ const WORKSPACE_TO_RHP: Partial Date: Thu, 23 Apr 2026 14:42:22 +0200 Subject: [PATCH 3/8] fix return when click already selected category --- .../categories/DynamicDefaultCategorySelectorPage.tsx | 6 +++++- .../categories/DynamicSpendCategorySelectorPage.tsx | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx b/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx index e57e9582de62..a0ef37ce18d3 100644 --- a/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx +++ b/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx @@ -26,7 +26,11 @@ function DynamicDefaultCategorySelectorPage({route}: DynamicDefaultCategorySelec const backPath = useDynamicBackPath(DYNAMIC_ROUTES.DEFAULT_CATEGORY_SELECTOR.path); const onCategorySelected = (selectedCategory: ListItem) => { - if (!selectedCategory.searchText || currentCategory === selectedCategory.searchText) { + if (!selectedCategory.searchText) { + return; + } + if (currentCategory === selectedCategory.searchText) { + Navigation.goBack(backPath); return; } setPolicyCustomUnitDefaultCategory(policyID, customUnitID, currentCategory, selectedCategory.searchText); diff --git a/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx b/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx index 44666e9bf9a9..86c90e88d7c5 100644 --- a/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx +++ b/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx @@ -28,7 +28,11 @@ function DynamicSpendCategorySelectorPage({route}: DynamicSpendCategorySelectorP const currentCategory = policy?.mccGroup?.[groupID]?.category ?? ''; const onCategorySelected = (selectedCategory: ListItem) => { - if (!selectedCategory.keyForList || currentCategory === selectedCategory.keyForList) { + if (!selectedCategory.keyForList) { + return; + } + if (currentCategory === selectedCategory.keyForList) { + Navigation.goBack(backPath); return; } setWorkspaceDefaultSpendCategory(policyID, groupID, selectedCategory.keyForList, policy?.mccGroup); From e095e0756e4bf654c031bcb5ecfeab8c92f4bd65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Musia=C5=82?= Date: Thu, 23 Apr 2026 16:52:33 +0200 Subject: [PATCH 4/8] dynamic route for isQuickSettingsFlow --- src/ROUTES.ts | 8 +------- src/SCREENS.ts | 1 - .../AppNavigator/ModalStackNavigators/index.tsx | 1 - .../linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts | 1 - src/libs/Navigation/linkingConfig/config.ts | 3 --- src/libs/Navigation/types.ts | 4 ---- .../categories/DynamicSpendCategorySelectorPage.tsx | 4 +--- .../categories/WorkspaceCategoriesSettingsPage.tsx | 6 +----- 8 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index b719cbad629d..291ff4eb4f50 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -295,7 +295,7 @@ const DYNAMIC_ROUTES = { }, SPEND_CATEGORY_SELECTOR: { path: 'spend-category-selector/:groupID', - entryScreens: [SCREENS.WORKSPACE.CATEGORIES_SETTINGS], + entryScreens: [SCREENS.WORKSPACE.CATEGORIES_SETTINGS, SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_SETTINGS], getRoute: (groupID: string) => `spend-category-selector/${groupID}` as const, }, DEFAULT_CATEGORY_SELECTOR: { @@ -1527,12 +1527,6 @@ const ROUTES = { // eslint-disable-next-line no-restricted-syntax -- Legacy route generation getRoute: (policyID: string, backTo = '') => getUrlWithBackToParam(`settings/${policyID}/categories/new`, backTo), }, - SETTINGS_SPEND_CATEGORY_SELECTOR: { - route: 'settings/:policyID/categories/spend-category-selector/:groupID', - getRoute: (policyID: string, groupID: string, backTo = '') => - // eslint-disable-next-line no-restricted-syntax -- Legacy route generation - getUrlWithBackToParam(`settings/${policyID}/categories/spend-category-selector/${groupID}` as const, backTo), - }, SETTINGS_CATEGORIES_IMPORT: { route: 'settings/:policyID/categories/import', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index a1dbf19d1dcb..e972f10e065a 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -429,7 +429,6 @@ const SCREENS = { SETTINGS_CATEGORIES_SETTINGS: 'Settings_Categories_Settings', SETTINGS_CATEGORY_CREATE: 'Settings_Category_Create', DYNAMIC_SETTINGS_CATEGORY_EDIT: 'Dynamic_Settings_Category_Edit', - SETTINGS_SPEND_CATEGORY_SELECTOR: 'Settings_Spend_Category_Selector', SETTINGS_CATEGORIES_ROOT: 'Settings_Categories', SETTINGS_CATEGORIES_IMPORT: 'Settings_Categories_Import', SETTINGS_CATEGORIES_IMPORTED: 'Settings_Categories_Imported', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 3defbe8ed3af..73f9bbeddf20 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -315,7 +315,6 @@ const CategoriesModalStackNavigator = createModalStackNavigator({ [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_SETTINGS]: () => require('../../../../pages/workspace/categories/WorkspaceCategoriesSettingsPage').default, [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORY_CREATE]: () => require('../../../../pages/workspace/categories/CreateCategoryPage').default, [SCREENS.SETTINGS_CATEGORIES.DYNAMIC_SETTINGS_CATEGORY_EDIT]: () => require('../../../../pages/workspace/categories/EditCategoryPage').default, - [SCREENS.SETTINGS_CATEGORIES.SETTINGS_SPEND_CATEGORY_SELECTOR]: () => require('../../../../pages/workspace/categories/DynamicSpendCategorySelectorPage').default, [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORY_SETTINGS]: () => require('../../../../pages/workspace/categories/CategorySettingsPage').default, [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_IMPORT]: () => require('../../../../pages/workspace/categories/ImportCategoriesPage').default, [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_IMPORTED]: () => require('../../../../pages/workspace/categories/ImportedCategoriesPage').default, diff --git a/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts b/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts index d1af804331c3..10e6056c9dfa 100755 --- a/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts +++ b/src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts @@ -211,7 +211,6 @@ const WORKSPACE_TO_RHP: Partial['config'] = { path: ROUTES.SETTINGS_CATEGORY_CREATE.route, }, [SCREENS.SETTINGS_CATEGORIES.DYNAMIC_SETTINGS_CATEGORY_EDIT]: DYNAMIC_ROUTES.SETTINGS_CATEGORY_EDIT.path, - [SCREENS.SETTINGS_CATEGORIES.SETTINGS_SPEND_CATEGORY_SELECTOR]: { - path: ROUTES.SETTINGS_SPEND_CATEGORY_SELECTOR.route, - }, [SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_IMPORT]: { path: ROUTES.SETTINGS_CATEGORIES_IMPORT.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 91ea19806c9e..128cd0e48016 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -442,10 +442,6 @@ type SettingsNavigatorParamList = { policyID: string; groupID: string; }; - [SCREENS.SETTINGS_CATEGORIES.SETTINGS_SPEND_CATEGORY_SELECTOR]: { - policyID: string; - groupID: string; - }; [SCREENS.WORKSPACE.DYNAMIC_DEFAULT_CATEGORY_SELECTOR]: { policyID: string; customUnitID: string; diff --git a/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx b/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx index 86c90e88d7c5..6cddf935e092 100644 --- a/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx +++ b/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx @@ -14,9 +14,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import {DYNAMIC_ROUTES} from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -type DynamicSpendCategorySelectorPageProps = - | PlatformStackScreenProps - | PlatformStackScreenProps; +type DynamicSpendCategorySelectorPageProps = PlatformStackScreenProps; function DynamicSpendCategorySelectorPage({route}: DynamicSpendCategorySelectorPageProps) { const {policyID, groupID} = route.params; diff --git a/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx b/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx index 83c82515891d..c27d257f9a1a 100644 --- a/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx +++ b/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx @@ -73,11 +73,7 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet return; } - Navigation.navigate( - isQuickSettingsFlow - ? ROUTES.SETTINGS_SPEND_CATEGORY_SELECTOR.getRoute(policyID, item.groupID, backTo) - : createDynamicRoute(DYNAMIC_ROUTES.SPEND_CATEGORY_SELECTOR.getRoute(item.groupID)), - ); + Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.SPEND_CATEGORY_SELECTOR.getRoute(item.groupID))); }; const selectionListHeaderContent = ( From c64a7337472686bf601a59c0025c09ab8eb5ca42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Musia=C5=82?= Date: Thu, 23 Apr 2026 17:43:16 +0200 Subject: [PATCH 5/8] add paddings --- .../workspace/categories/DynamicDefaultCategorySelectorPage.tsx | 1 - .../workspace/categories/DynamicSpendCategorySelectorPage.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx b/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx index a0ef37ce18d3..8274da26860d 100644 --- a/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx +++ b/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx @@ -40,7 +40,6 @@ function DynamicDefaultCategorySelectorPage({route}: DynamicDefaultCategorySelec return ( Date: Fri, 24 Apr 2026 13:48:31 +0200 Subject: [PATCH 6/8] Add AccessOrNotFoundWrapper --- .../DynamicDefaultCategorySelectorPage.tsx | 42 +++++++++++-------- .../DynamicSpendCategorySelectorPage.tsx | 42 +++++++++++-------- 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx b/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx index 8274da26860d..88cd0f486e39 100644 --- a/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx +++ b/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx @@ -10,7 +10,9 @@ import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; +import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import {setPolicyCustomUnitDefaultCategory} from '@userActions/Policy/Category'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import {DYNAMIC_ROUTES} from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; @@ -38,24 +40,30 @@ function DynamicDefaultCategorySelectorPage({route}: DynamicDefaultCategorySelec }; return ( - - Navigation.goBack(backPath)} - /> - - + + Navigation.goBack(backPath)} + /> + + + ); } diff --git a/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx b/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx index 97a25ca4f12b..c1d27824d44d 100644 --- a/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx +++ b/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx @@ -9,7 +9,9 @@ import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; +import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import {setWorkspaceDefaultSpendCategory} from '@userActions/Policy/Policy'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import {DYNAMIC_ROUTES} from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; @@ -38,24 +40,30 @@ function DynamicSpendCategorySelectorPage({route}: DynamicSpendCategorySelectorP }; return ( - - Navigation.goBack(backPath)} - /> - - + + Navigation.goBack(backPath)} + /> + + + ); } From b4ca0f785ba072e82ec4bd30d2e8c8613a3ddaa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Musia=C5=82?= Date: Mon, 27 Apr 2026 18:19:18 +0200 Subject: [PATCH 7/8] review fixes --- src/components/CategorySelector/index.tsx | 6 +++--- .../categories/DynamicDefaultCategorySelectorPage.tsx | 3 ++- .../categories/DynamicSpendCategorySelectorPage.tsx | 3 ++- .../distanceRates/PolicyDistanceRatesSettingsPage.tsx | 4 ++-- .../workspace/perDiem/WorkspacePerDiemSettingsPage.tsx | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/CategorySelector/index.tsx b/src/components/CategorySelector/index.tsx index 7448435963a3..6f79867cd269 100644 --- a/src/components/CategorySelector/index.tsx +++ b/src/components/CategorySelector/index.tsx @@ -8,7 +8,7 @@ import Navigation from '@libs/Navigation/Navigation'; import CONST from '@src/CONST'; import {DYNAMIC_ROUTES} from '@src/ROUTES'; -type CategorySelectorProps = { +type CustomUnitDefaultCategorySelectorProps = { /** Currently selected category */ defaultValue?: string; @@ -25,7 +25,7 @@ type CategorySelectorProps = { customUnitID: string; }; -function CategorySelector({defaultValue = '', wrapperStyle, label, focused, customUnitID}: CategorySelectorProps) { +function CustomUnitDefaultCategorySelector({defaultValue = '', wrapperStyle, label, focused, customUnitID}: CustomUnitDefaultCategorySelectorProps) { const styles = useThemeStyles(); const decodedCategoryName = getDecodedCategoryName(defaultValue); @@ -49,4 +49,4 @@ function CategorySelector({defaultValue = '', wrapperStyle, label, focused, cust ); } -export default CategorySelector; +export default CustomUnitDefaultCategorySelector; diff --git a/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx b/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx index 88cd0f486e39..5dd84768f837 100644 --- a/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx +++ b/src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx @@ -7,6 +7,7 @@ import useDynamicBackPath from '@hooks/useDynamicBackPath'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; +import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; @@ -23,7 +24,7 @@ function DynamicDefaultCategorySelectorPage({route}: DynamicDefaultCategorySelec const {policyID, customUnitID} = route.params; const styles = useThemeStyles(); const {translate} = useLocalize(); - const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(policyID)}`); const currentCategory = policy?.customUnits?.[customUnitID]?.defaultCategory ?? ''; const backPath = useDynamicBackPath(DYNAMIC_ROUTES.DEFAULT_CATEGORY_SELECTOR.path); diff --git a/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx b/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx index c1d27824d44d..9d4aa2db8d4b 100644 --- a/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx +++ b/src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx @@ -6,6 +6,7 @@ import type {ListItem} from '@components/SelectionList/types'; import useDynamicBackPath from '@hooks/useDynamicBackPath'; import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; +import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; @@ -23,7 +24,7 @@ function DynamicSpendCategorySelectorPage({route}: DynamicSpendCategorySelectorP const styles = useThemeStyles(); const backPath = useDynamicBackPath(DYNAMIC_ROUTES.SPEND_CATEGORY_SELECTOR.path); - const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(policyID)}`); const label = groupID.charAt(0).toUpperCase() + groupID.slice(1); const currentCategory = policy?.mccGroup?.[groupID]?.category ?? ''; diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx index 2059b5df6367..9226a9c88fb7 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {View} from 'react-native'; import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; -import CategorySelector from '@components/CategorySelector'; +import CustomUnitDefaultCategorySelector from '@components/CategorySelector'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RenderHTML from '@components/RenderHTML'; @@ -113,7 +113,7 @@ function PolicyDistanceRatesSettingsPage({route}: PolicyDistanceRatesSettingsPag errorRowStyles={styles.mh5} onClose={() => clearErrorFields('defaultCategory')} > - clearErrorFields('defaultCategory')} > - Date: Mon, 27 Apr 2026 18:21:50 +0200 Subject: [PATCH 8/8] rename dir --- .../index.tsx | 0 .../workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx | 2 +- src/pages/workspace/perDiem/WorkspacePerDiemSettingsPage.tsx | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/components/{CategorySelector => CustomUnitDefaultCategorySelector}/index.tsx (100%) diff --git a/src/components/CategorySelector/index.tsx b/src/components/CustomUnitDefaultCategorySelector/index.tsx similarity index 100% rename from src/components/CategorySelector/index.tsx rename to src/components/CustomUnitDefaultCategorySelector/index.tsx diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx index 9226a9c88fb7..7649cc3f801d 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {View} from 'react-native'; import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; -import CustomUnitDefaultCategorySelector from '@components/CategorySelector'; +import CustomUnitDefaultCategorySelector from '@components/CustomUnitDefaultCategorySelector'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RenderHTML from '@components/RenderHTML'; diff --git a/src/pages/workspace/perDiem/WorkspacePerDiemSettingsPage.tsx b/src/pages/workspace/perDiem/WorkspacePerDiemSettingsPage.tsx index 5b02e497ecfc..b28edbdb05ca 100644 --- a/src/pages/workspace/perDiem/WorkspacePerDiemSettingsPage.tsx +++ b/src/pages/workspace/perDiem/WorkspacePerDiemSettingsPage.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {View} from 'react-native'; import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; -import CustomUnitDefaultCategorySelector from '@components/CategorySelector'; +import CustomUnitDefaultCategorySelector from '@components/CustomUnitDefaultCategorySelector'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper';