Skip to content

Commit

Permalink
Merge pull request #53316 from nkdengineer/fix/53309
Browse files Browse the repository at this point in the history
[CP Staging] Fix categorize flow

(cherry picked from commit b68bb0a)

(CP triggered by mountiny)
  • Loading branch information
mountiny authored and OSBotify committed Nov 29, 2024
1 parent e0e1be5 commit 717ce03
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/libs/actions/Policy/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ function deleteWorkspaceCategories(policyID: string, categoryNamesToDelete: stri
API.write(WRITE_COMMANDS.DELETE_WORKSPACE_CATEGORIES, parameters, onyxData);
}

function enablePolicyCategories(policyID: string, enabled: boolean) {
function enablePolicyCategories(policyID: string, enabled: boolean, shouldNavigate = true) {
const onyxUpdatesToDisableCategories: OnyxUpdate[] = [];
if (!enabled) {
onyxUpdatesToDisableCategories.push(
Expand Down Expand Up @@ -1017,7 +1017,7 @@ function enablePolicyCategories(policyID: string, enabled: boolean) {

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

if (enabled && getIsNarrowLayout()) {
if (enabled && getIsNarrowLayout() && shouldNavigate) {
navigateWhenEnableFeature(policyID);
}
}
Expand Down
23 changes: 14 additions & 9 deletions src/pages/iou/request/step/IOURequestStepCategory.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import lodashIsEmpty from 'lodash/isEmpty';
import React, {useEffect} from 'react';
import {ActivityIndicator, View} from 'react-native';
import {ActivityIndicator, InteractionManager, View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView';
import Button from '@components/Button';
Expand Down Expand Up @@ -167,14 +167,19 @@ function IOURequestStepCategory({
large
success
style={[styles.w100]}
onPress={() =>
Navigation.navigate(
ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(
policy?.id ?? '-1',
ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, iouType, transactionID, report?.reportID ?? '-1', backTo, reportActionID),
),
)
}
onPress={() => {
if (!policy?.areCategoriesEnabled) {
Category.enablePolicyCategories(policy?.id ?? '-1', true, false);
}
InteractionManager.runAfterInteractions(() => {
Navigation.navigate(
ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(
policy?.id ?? '-1',
ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, iouType, transactionID, report?.reportID ?? '-1', backTo, reportActionID),
),
);
});
}}
text={translate('workspace.categories.editCategories')}
pressOnEnter
/>
Expand Down
1 change: 1 addition & 0 deletions src/pages/iou/request/step/IOURequestStepUpgrade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function IOURequestStepUpgrade({
searchText: policyDataRef.current?.policyName,
},
]);
Navigation.goBack();
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, policyDataRef.current?.expenseChatReportID ?? '-1'));
}}
policyName=""
Expand Down

0 comments on commit 717ce03

Please sign in to comment.