Skip to content

Commit b68bb0a

Browse files
authored
Merge pull request #53316 from nkdengineer/fix/53309
[CP Staging] Fix categorize flow
2 parents decb695 + 05fd93d commit b68bb0a

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/libs/actions/Policy/Category.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ function deleteWorkspaceCategories(policyID: string, categoryNamesToDelete: stri
946946
API.write(WRITE_COMMANDS.DELETE_WORKSPACE_CATEGORIES, parameters, onyxData);
947947
}
948948

949-
function enablePolicyCategories(policyID: string, enabled: boolean) {
949+
function enablePolicyCategories(policyID: string, enabled: boolean, shouldNavigate = true) {
950950
const onyxUpdatesToDisableCategories: OnyxUpdate[] = [];
951951
if (!enabled) {
952952
onyxUpdatesToDisableCategories.push(
@@ -1017,7 +1017,7 @@ function enablePolicyCategories(policyID: string, enabled: boolean) {
10171017

10181018
API.write(WRITE_COMMANDS.ENABLE_POLICY_CATEGORIES, parameters, onyxData);
10191019

1020-
if (enabled && getIsNarrowLayout()) {
1020+
if (enabled && getIsNarrowLayout() && shouldNavigate) {
10211021
navigateWhenEnableFeature(policyID);
10221022
}
10231023
}

src/pages/iou/request/step/IOURequestStepCategory.tsx

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import lodashIsEmpty from 'lodash/isEmpty';
22
import React, {useEffect} from 'react';
3-
import {ActivityIndicator, View} from 'react-native';
3+
import {ActivityIndicator, InteractionManager, View} from 'react-native';
44
import {useOnyx} from 'react-native-onyx';
55
import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView';
66
import Button from '@components/Button';
@@ -167,14 +167,19 @@ function IOURequestStepCategory({
167167
large
168168
success
169169
style={[styles.w100]}
170-
onPress={() =>
171-
Navigation.navigate(
172-
ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(
173-
policy?.id ?? '-1',
174-
ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, iouType, transactionID, report?.reportID ?? '-1', backTo, reportActionID),
175-
),
176-
)
177-
}
170+
onPress={() => {
171+
if (!policy?.areCategoriesEnabled) {
172+
Category.enablePolicyCategories(policy?.id ?? '-1', true, false);
173+
}
174+
InteractionManager.runAfterInteractions(() => {
175+
Navigation.navigate(
176+
ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(
177+
policy?.id ?? '-1',
178+
ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, iouType, transactionID, report?.reportID ?? '-1', backTo, reportActionID),
179+
),
180+
);
181+
});
182+
}}
178183
text={translate('workspace.categories.editCategories')}
179184
pressOnEnter
180185
/>

src/pages/iou/request/step/IOURequestStepUpgrade.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function IOURequestStepUpgrade({
5656
searchText: policyDataRef.current?.policyName,
5757
},
5858
]);
59+
Navigation.goBack();
5960
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, policyDataRef.current?.expenseChatReportID ?? '-1'));
6061
}}
6162
policyName=""

0 commit comments

Comments
 (0)