diff --git a/src/components/Search/SearchRouter/SearchButton.tsx b/src/components/Search/SearchRouter/SearchButton.tsx index 618afb07cc84..d7242529cb13 100644 --- a/src/components/Search/SearchRouter/SearchButton.tsx +++ b/src/components/Search/SearchRouter/SearchButton.tsx @@ -4,7 +4,7 @@ import * as Expensicons from '@components/Icon/Expensicons'; import {PressableWithoutFeedback} from '@components/Pressable'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as SearchUtils from '@libs/SearchUtils'; +import Permissions from '@libs/Permissions'; import {useSearchRouterContext} from './SearchRouterContext'; function SearchButton() { @@ -12,7 +12,7 @@ function SearchButton() { const theme = useTheme(); const {toggleSearchRouter} = useSearchRouterContext(); - if (!SearchUtils.shouldDisplayNewSearchRouter()) { + if (!Permissions.canUseNewSearchRouter()) { return; } diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 8c47100e465b..7f7e89ad3585 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -2,6 +2,7 @@ import type {OnyxEntry} from 'react-native-onyx'; import CONST from '@src/CONST'; import type {IOUType} from '@src/CONST'; import type Beta from '@src/types/onyx/Beta'; +import * as Environment from './Environment/Environment'; function canUseAllBetas(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.ALL); @@ -49,6 +50,17 @@ function canUseCombinedTrackSubmit(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.COMBINED_TRACK_SUBMIT); } +/** + * New Search Router is under construction and for now should be displayed only in dev to allow developers to work on it. + * We are not using BETA for this feature, as betas are heavier to cleanup, + * and the development of new router is expected to take 2-3 weeks at most + * + * After everything is implemented this function can be removed, as we will always use SearchRouter in the App. + */ +function canUseNewSearchRouter() { + return Environment.isDevelopment(); +} + /** * Link previews are temporarily disabled. */ @@ -68,4 +80,5 @@ export default { canUseNewDotCopilot, canUseWorkspaceRules, canUseCombinedTrackSubmit, + canUseNewSearchRouter, }; diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts index dd4bfa09e279..549cdfc3b52d 100644 --- a/src/libs/SearchUtils.ts +++ b/src/libs/SearchUtils.ts @@ -4,7 +4,6 @@ import ChatListItem from '@components/SelectionList/ChatListItem'; import ReportListItem from '@components/SelectionList/Search/ReportListItem'; import TransactionListItem from '@components/SelectionList/Search/TransactionListItem'; import type {ListItem, ReportActionListItemType, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types'; -import * as Environment from '@libs/Environment/Environment'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -693,15 +692,6 @@ function isCannedSearchQuery(queryJSON: SearchQueryJSON) { return !queryJSON.filters; } -/** - * New Search Router is under construction and for now should be displayed only in dev. - * - * After everything is implemented this function can be removed, as we will start to always use SearchRouter. - */ -function shouldDisplayNewSearchRouter() { - return Environment.isDevelopment(); -} - export { buildQueryStringFromFilters, buildSearchQueryJSON, @@ -725,5 +715,4 @@ export { getExpenseTypeTranslationKey, getChatFiltersTranslationKey, getChatStatusTranslationKey, - shouldDisplayNewSearchRouter, };