diff --git a/src/pages/workspace/categories/CategoryGLCodePage.tsx b/src/pages/workspace/categories/CategoryGLCodePage.tsx index 3fa6dadc3d64..01cb73182151 100644 --- a/src/pages/workspace/categories/CategoryGLCodePage.tsx +++ b/src/pages/workspace/categories/CategoryGLCodePage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useCallback} from 'react'; import {useOnyx} from 'react-native-onyx'; import FormProvider from '@components/Form/FormProvider'; @@ -33,7 +32,7 @@ function CategoryGLCodePage({route}: EditCategoryPageProps) { const categoryName = route.params.categoryName; const glCode = policyCategories?.[categoryName]?.['GL Code']; const {inputCallbackRef} = useAutoFocusInput(); - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const editGLCode = useCallback( (values: FormOnyxValues) => { diff --git a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx index 41211e3eb278..a489d9db656c 100644 --- a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx +++ b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useCallback} from 'react'; import {useOnyx} from 'react-native-onyx'; import FormProvider from '@components/Form/FormProvider'; @@ -33,7 +32,7 @@ function CategoryPayrollCodePage({route}: EditCategoryPageProps) { const categoryName = route.params.categoryName; const payrollCode = policyCategories?.[categoryName]?.['Payroll Code']; const {inputCallbackRef} = useAutoFocusInput(); - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const editPayrollCode = useCallback( (values: FormOnyxValues) => { diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index c8195ed83307..b371f9b799ab 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useEffect, useMemo, useState} from 'react'; import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -54,7 +53,7 @@ function CategorySettingsPage({ const policyCategoryExpenseLimitType = policyCategory?.expenseLimitType ?? CONST.POLICY.EXPENSE_LIMIT_TYPES.EXPENSE; const areCommentsRequired = policyCategory?.areCommentsRequired ?? false; - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const navigateBack = () => { Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(policyID, backTo) : undefined); diff --git a/src/pages/workspace/categories/CreateCategoryPage.tsx b/src/pages/workspace/categories/CreateCategoryPage.tsx index 60f85f66f604..c862be9fc60a 100644 --- a/src/pages/workspace/categories/CreateCategoryPage.tsx +++ b/src/pages/workspace/categories/CreateCategoryPage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useCallback} from 'react'; import {useOnyx} from 'react-native-onyx'; import type {FormOnyxValues} from '@components/Form/types'; @@ -24,7 +23,7 @@ function CreateCategoryPage({route}: CreateCategoryPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const backTo = route.params?.backTo; - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const createCategory = useCallback( (values: FormOnyxValues) => { diff --git a/src/pages/workspace/categories/EditCategoryPage.tsx b/src/pages/workspace/categories/EditCategoryPage.tsx index 92491b4911a5..330c47f0197f 100644 --- a/src/pages/workspace/categories/EditCategoryPage.tsx +++ b/src/pages/workspace/categories/EditCategoryPage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useCallback} from 'react'; import {useOnyx} from 'react-native-onyx'; import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; @@ -25,7 +24,7 @@ function EditCategoryPage({route}: EditCategoryPageProps) { const {translate} = useLocalize(); const currentCategoryName = route.params.categoryName; const backTo = route.params?.backTo; - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const validate = useCallback( (values: FormOnyxValues) => { diff --git a/src/pages/workspace/categories/ImportCategoriesPage.tsx b/src/pages/workspace/categories/ImportCategoriesPage.tsx index 1c1d6306f065..82afe6dfc812 100644 --- a/src/pages/workspace/categories/ImportCategoriesPage.tsx +++ b/src/pages/workspace/categories/ImportCategoriesPage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React from 'react'; import ImportSpreedsheet from '@components/ImportSpreadsheet'; import usePolicy from '@hooks/usePolicy'; @@ -16,7 +15,7 @@ function ImportCategoriesPage({route}: ImportCategoriesPageProps) { const backTo = route.params.backTo; const policy = usePolicy(policyID); const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy); - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; if (hasAccountingConnections) { return ; diff --git a/src/pages/workspace/categories/ImportedCategoriesPage.tsx b/src/pages/workspace/categories/ImportedCategoriesPage.tsx index e65080bf73df..138c7ea681df 100644 --- a/src/pages/workspace/categories/ImportedCategoriesPage.tsx +++ b/src/pages/workspace/categories/ImportedCategoriesPage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useCallback, useState} from 'react'; import {useOnyx} from 'react-native-onyx'; import ConfirmModal from '@components/ConfirmModal'; @@ -35,7 +34,7 @@ function ImportedCategoriesPage({route}: ImportedCategoriesPageProps) { const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`); const policy = usePolicy(policyID); const columnNames = generateColumnNames(spreadsheet?.data?.length ?? 0); - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const getColumnRoles = (): ColumnRole[] => { const roles = []; diff --git a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx index 56ec6651ee25..02822c8b66d5 100644 --- a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx +++ b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx @@ -1,6 +1,5 @@ import {useFocusEffect, useIsFocused} from '@react-navigation/native'; import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import lodashSortBy from 'lodash/sortBy'; import React, {useCallback, useEffect, useMemo, useState} from 'react'; import {ActivityIndicator, View} from 'react-native'; @@ -76,7 +75,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyId}`); const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0; const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy); - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const canSelectMultiple = shouldUseNarrowLayout ? selectionMode?.isEnabled : true; diff --git a/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx b/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx index 19168cc85822..2b3fae8e972c 100644 --- a/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx +++ b/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx @@ -1,4 +1,3 @@ -import isEmpty from 'lodash/isEmpty'; import React, {useMemo, useState} from 'react'; import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -48,7 +47,7 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet const [isSelectorModalVisible, setIsSelectorModalVisible] = useState(false); const [categoryID, setCategoryID] = useState(); const [groupID, setGroupID] = useState(); - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = backTo; const toggleSubtitle = isConnectedToAccounting && currentConnectionName ? `${translate('workspace.categories.needCategoryForExportToIntegration')} ${currentConnectionName}.` : undefined; diff --git a/src/pages/workspace/tags/EditTagPage.tsx b/src/pages/workspace/tags/EditTagPage.tsx index 7bf3202769a7..d20fce3b3dd4 100644 --- a/src/pages/workspace/tags/EditTagPage.tsx +++ b/src/pages/workspace/tags/EditTagPage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useCallback} from 'react'; import {Keyboard} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -33,7 +32,7 @@ function EditTagPage({route}: EditTagPageProps) { const {translate} = useLocalize(); const {inputCallbackRef} = useAutoFocusInput(); const currentTagName = PolicyUtils.getCleanedTagName(route.params.tagName); - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const validate = useCallback( (values: FormOnyxValues) => { diff --git a/src/pages/workspace/tags/ImportTagsPage.tsx b/src/pages/workspace/tags/ImportTagsPage.tsx index 83d822888f18..1bbe22750210 100644 --- a/src/pages/workspace/tags/ImportTagsPage.tsx +++ b/src/pages/workspace/tags/ImportTagsPage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React from 'react'; import ImportSpreedsheet from '@components/ImportSpreadsheet'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; @@ -11,7 +10,7 @@ type ImportTagsPageProps = StackScreenProps PolicyUtils.getTagLists(policyTags), [policyTags]); const policy = usePolicy(policyID); const columnNames = generateColumnNames(spreadsheet?.data?.length ?? 0); - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const getColumnRoles = (): ColumnRole[] => { const roles = []; @@ -129,7 +128,7 @@ function ImportedTagsPage({route}: ImportedTagsPageProps) { > Navigation.goBack(backTo ? ROUTES.SETTINGS_TAGS_IMPORT.getRoute(policyID, backTo) : ROUTES.WORKSPACE_TAGS_IMPORT.getRoute(policyID))} + onBackButtonPress={() => Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_TAGS_IMPORT.getRoute(policyID, backTo) : ROUTES.WORKSPACE_TAGS_IMPORT.getRoute(policyID))} /> { Navigation.goBack( diff --git a/src/pages/workspace/tags/TagGLCodePage.tsx b/src/pages/workspace/tags/TagGLCodePage.tsx index 4c8cd1a8672f..df93b7b61b97 100644 --- a/src/pages/workspace/tags/TagGLCodePage.tsx +++ b/src/pages/workspace/tags/TagGLCodePage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useCallback} from 'react'; import {useOnyx} from 'react-native-onyx'; import FormProvider from '@components/Form/FormProvider'; @@ -37,7 +36,7 @@ function TagGLCodePage({route}: EditTagGLCodePageProps) { const orderWeight = route.params.orderWeight; const {tags} = PolicyUtils.getTagList(policyTags, orderWeight); const glCode = tags?.[route.params.tagName]?.['GL Code']; - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const goBack = useCallback(() => { Navigation.goBack( diff --git a/src/pages/workspace/tags/TagSettingsPage.tsx b/src/pages/workspace/tags/TagSettingsPage.tsx index 64d644a640ff..e57571ca0a5f 100644 --- a/src/pages/workspace/tags/TagSettingsPage.tsx +++ b/src/pages/workspace/tags/TagSettingsPage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useEffect, useMemo} from 'react'; import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -42,7 +41,7 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) { const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy); const {canUseCategoryAndTagApprovers} = usePermissions(); const [isDeleteTagModalOpen, setIsDeleteTagModalOpen] = React.useState(false); - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const currentPolicyTag = policyTag.tags[tagName] ?? Object.values(policyTag.tags ?? {}).find((tag) => tag.previousTagName === tagName); diff --git a/src/pages/workspace/tags/WorkspaceCreateTagPage.tsx b/src/pages/workspace/tags/WorkspaceCreateTagPage.tsx index a7deb126fc43..a7900fe957a2 100644 --- a/src/pages/workspace/tags/WorkspaceCreateTagPage.tsx +++ b/src/pages/workspace/tags/WorkspaceCreateTagPage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useCallback} from 'react'; import {Keyboard} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -33,7 +32,7 @@ function CreateTagPage({route}: CreateTagPageProps) { const {translate} = useLocalize(); const {inputCallbackRef} = useAutoFocusInput(); const backTo = route.params.backTo; - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const validate = useCallback( (values: FormOnyxValues) => { diff --git a/src/pages/workspace/tags/WorkspaceEditTagsPage.tsx b/src/pages/workspace/tags/WorkspaceEditTagsPage.tsx index 2365e34451aa..f243c695e84a 100644 --- a/src/pages/workspace/tags/WorkspaceEditTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceEditTagsPage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -32,7 +31,7 @@ function WorkspaceEditTagsPage({route}: WorkspaceEditTagsPageProps) { const taglistName = useMemo(() => PolicyUtils.getTagListName(policyTags, route.params.orderWeight), [policyTags, route.params.orderWeight]); const {inputCallbackRef} = useAutoFocusInput(); const backTo = route.params.backTo; - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const validateTagName = useCallback( (values: FormOnyxValues) => { diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index eb25d7407d7a..5574b5c78421 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -1,6 +1,5 @@ import {useFocusEffect, useIsFocused} from '@react-navigation/native'; import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import lodashSortBy from 'lodash/sortBy'; import React, {useCallback, useEffect, useMemo, useState} from 'react'; import {ActivityIndicator, View} from 'react-native'; @@ -75,7 +74,7 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) { const fetchTags = useCallback(() => { Tag.openPolicyTagsPage(policyID); }, [policyID]); - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const {isOffline} = useNetwork({onReconnect: fetchTags}); diff --git a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx index 2a54c77890af..3fadba088648 100644 --- a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; @@ -67,7 +66,7 @@ function WorkspaceTagsSettingsPage({route}: WorkspaceTagsSettingsPageProps) { }, [policyID], ); - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const getTagsSettings = (policy: OnyxEntry) => ( diff --git a/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx b/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx index 7a25d44ab875..c7bd1cfbacda 100644 --- a/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx @@ -1,6 +1,5 @@ import {useIsFocused} from '@react-navigation/native'; import type {StackScreenProps} from '@react-navigation/stack'; -import isEmpty from 'lodash/isEmpty'; import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {ActivityIndicator, View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -60,7 +59,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) { const {selectionMode} = useMobileSelectionMode(); const currentTagListName = useMemo(() => PolicyUtils.getTagListName(policyTags, route.params.orderWeight), [policyTags, route.params.orderWeight]); const currentPolicyTag = policyTags?.[currentTagListName]; - const isQuickSettingsFlow = !isEmpty(backTo); + const isQuickSettingsFlow = !!backTo; const fetchTags = useCallback(() => { Tag.openPolicyTagsPage(policyID);