-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Migrate CategorySelectorModal to be nav RHP #88576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mountiny
merged 13 commits into
Expensify:main
from
software-mansion-labs:feat/migrate-category-selector-to-navigation
May 1, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c38cbcb
Migrate CategorySelectorModal to be nv RHP
jmusial 93b33f2
Remove old linking config
jmusial 013feee
fix return when click already selected category
jmusial e095e07
dynamic route for isQuickSettingsFlow
jmusial 03a0f5c
Merge branch 'main' into feat/migrate-category-selector-to-navigation
jmusial c64a733
add paddings
jmusial 3f88b9c
Merge branch 'main' into feat/migrate-category-selector-to-navigation
jmusial 234bdfd
Merge branch 'main' into feat/migrate-category-selector-to-navigation
jmusial 8f6c812
Add AccessOrNotFoundWrapper
jmusial b4ca0f7
review fixes
jmusial 8250380
Merge branch 'main' into feat/migrate-category-selector-to-navigation
jmusial 04edde0
rename dir
jmusial 036c7cd
Merge branch 'main' into feat/migrate-category-selector-to-navigation
jmusial File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
src/components/CustomUnitDefaultCategorySelector/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import React from 'react'; | ||
| import type {StyleProp, ViewStyle} from 'react-native'; | ||
| import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
| 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 {DYNAMIC_ROUTES} from '@src/ROUTES'; | ||
|
|
||
| type CustomUnitDefaultCategorySelectorProps = { | ||
| /** Currently selected category */ | ||
| defaultValue?: string; | ||
|
|
||
| /** Label to display on field */ | ||
| label: string; | ||
|
|
||
| /** Any additional styles to apply */ | ||
| wrapperStyle: StyleProp<ViewStyle>; | ||
|
|
||
| /** Whether item is focused or active */ | ||
| focused?: boolean; | ||
|
|
||
| /** The custom unit ID to update when selecting a category */ | ||
| customUnitID: string; | ||
| }; | ||
|
|
||
| function CustomUnitDefaultCategorySelector({defaultValue = '', wrapperStyle, label, focused, customUnitID}: CustomUnitDefaultCategorySelectorProps) { | ||
| const styles = useThemeStyles(); | ||
|
|
||
| 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 ( | ||
| <MenuItemWithTopDescription | ||
| shouldShowRightIcon | ||
| title={decodedCategoryName} | ||
| description={label} | ||
| descriptionTextStyle={descStyle} | ||
| onPress={onPress} | ||
| wrapperStyle={wrapperStyle} | ||
| focused={focused} | ||
| sentryLabel={CONST.SENTRY_LABEL.WORKSPACE.RULES.CATEGORY_SELECTOR} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export default CustomUnitDefaultCategorySelector; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/pages/workspace/categories/DynamicDefaultCategorySelectorPage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| 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 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'; | ||
| 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'; | ||
|
|
||
| type DynamicDefaultCategorySelectorPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.DYNAMIC_DEFAULT_CATEGORY_SELECTOR>; | ||
|
|
||
| function DynamicDefaultCategorySelectorPage({route}: DynamicDefaultCategorySelectorPageProps) { | ||
| const {policyID, customUnitID} = route.params; | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
| const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(policyID)}`); | ||
| const currentCategory = policy?.customUnits?.[customUnitID]?.defaultCategory ?? ''; | ||
| const backPath = useDynamicBackPath(DYNAMIC_ROUTES.DEFAULT_CATEGORY_SELECTOR.path); | ||
|
|
||
| const onCategorySelected = (selectedCategory: ListItem) => { | ||
| if (!selectedCategory.searchText) { | ||
| return; | ||
| } | ||
| if (currentCategory === selectedCategory.searchText) { | ||
| Navigation.goBack(backPath); | ||
| return; | ||
| } | ||
| setPolicyCustomUnitDefaultCategory(policyID, customUnitID, currentCategory, selectedCategory.searchText); | ||
| Navigation.goBack(backPath); | ||
| }; | ||
|
|
||
| return ( | ||
| <AccessOrNotFoundWrapper | ||
| policyID={policyID} | ||
| accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} | ||
| featureName={CONST.POLICY.MORE_FEATURES.ARE_CATEGORIES_ENABLED} | ||
| > | ||
| <ScreenWrapper | ||
| style={styles.pb0} | ||
| enableEdgeToEdgeBottomSafeAreaPadding | ||
| shouldEnableKeyboardAvoidingView={false} | ||
| testID="DynamicDefaultCategorySelectorPage" | ||
| > | ||
| <HeaderWithBackButton | ||
| title={translate('workspace.common.defaultCategory')} | ||
| shouldShowBackButton | ||
| onBackButtonPress={() => Navigation.goBack(backPath)} | ||
| /> | ||
| <CategoryPicker | ||
| policyID={policyID} | ||
| selectedCategory={currentCategory} | ||
| onSubmit={onCategorySelected} | ||
| addBottomSafeAreaPadding | ||
| /> | ||
| </ScreenWrapper> | ||
| </AccessOrNotFoundWrapper> | ||
| ); | ||
| } | ||
|
|
||
| export default DynamicDefaultCategorySelectorPage; |
71 changes: 71 additions & 0 deletions
71
src/pages/workspace/categories/DynamicSpendCategorySelectorPage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| 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 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'; | ||
| 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'; | ||
|
|
||
| type DynamicSpendCategorySelectorPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.DYNAMIC_SPEND_CATEGORY_SELECTOR>; | ||
|
|
||
| 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}${getNonEmptyStringOnyxID(policyID)}`); | ||
| const label = groupID.charAt(0).toUpperCase() + groupID.slice(1); | ||
| const currentCategory = policy?.mccGroup?.[groupID]?.category ?? ''; | ||
|
|
||
| const onCategorySelected = (selectedCategory: ListItem) => { | ||
| if (!selectedCategory.keyForList) { | ||
| return; | ||
| } | ||
| if (currentCategory === selectedCategory.keyForList) { | ||
| Navigation.goBack(backPath); | ||
| return; | ||
| } | ||
| setWorkspaceDefaultSpendCategory(policyID, groupID, selectedCategory.keyForList, policy?.mccGroup); | ||
| Navigation.goBack(backPath); | ||
| }; | ||
|
|
||
| return ( | ||
| <AccessOrNotFoundWrapper | ||
| policyID={policyID} | ||
| accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} | ||
| featureName={CONST.POLICY.MORE_FEATURES.ARE_CATEGORIES_ENABLED} | ||
| > | ||
| <ScreenWrapper | ||
| style={styles.pb0} | ||
| enableEdgeToEdgeBottomSafeAreaPadding | ||
| shouldEnableKeyboardAvoidingView={false} | ||
| testID="DynamicSpendCategorySelectorPage" | ||
| > | ||
| <HeaderWithBackButton | ||
| title={label} | ||
| shouldShowBackButton | ||
| onBackButtonPress={() => Navigation.goBack(backPath)} | ||
| /> | ||
| <CategoryPicker | ||
| policyID={policyID} | ||
| selectedCategory={currentCategory} | ||
| onSubmit={onCategorySelected} | ||
| addBottomSafeAreaPadding | ||
| /> | ||
| </ScreenWrapper> | ||
| </AccessOrNotFoundWrapper> | ||
| ); | ||
| } | ||
|
|
||
| export default DynamicSpendCategorySelectorPage; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.