Skip to content
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

fix: remove categorize page from navigation stack #45560

Merged
merged 4 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,13 @@ function isDeletedPolicyEmployee(policyEmployee: PolicyEmployee, isOffline: bool
return !isOffline && policyEmployee.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyEmployee.errors);
}

function hasNoPolicyOtherThanPersonalType() {
return (
Object.values(allPolicies ?? {}).filter((policy) => policy && policy.type !== CONST.POLICY.TYPE.PERSONAL && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE)
.length === 0
);
}

export {
canEditTaxRate,
extractPolicyIDFromPath,
Expand Down Expand Up @@ -861,6 +868,7 @@ export {
getNameFromNetSuiteCustomField,
isNetSuiteCustomFieldPropertyEditable,
getCurrentSageIntacctEntityName,
hasNoPolicyOtherThanPersonalType,
};

export type {MemberEmailsToAccountIDs};
1 change: 1 addition & 0 deletions src/pages/iou/request/step/IOURequestStepCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function IOURequestStepCategory({
IOU.setMoneyRequestCategory(transactionID, updatedCategory);

if (action === CONST.IOU.ACTION.CATEGORIZE) {
Navigation.goBack();
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(action, iouType, transactionID, report?.reportID ?? '-1'));
return;
}
Expand Down
9 changes: 8 additions & 1 deletion src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as IOUUtils from '@libs/IOUUtils';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import playSound, {SOUNDS} from '@libs/Sound';
import * as TransactionUtils from '@libs/TransactionUtils';
Expand All @@ -36,8 +37,8 @@ import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';
import type {Receipt} from '@src/types/onyx/Transaction';
import type {WithFullTransactionOrNotFoundProps} from './withFullTransactionOrNotFound';
import withFullTransactionOrNotFound from './withFullTransactionOrNotFound';
import withWritableReportOrNotFound from './withWritableReportOrNotFound';
import type {WithWritableReportOrNotFoundProps} from './withWritableReportOrNotFound';
import withWritableReportOrNotFound from './withWritableReportOrNotFound';

type IOURequestStepConfirmationOnyxProps = {
/** The policy of the report */
Expand Down Expand Up @@ -192,6 +193,12 @@ function IOURequestStepConfirmation({
}, [transactionID, requestType, defaultCategory]);

const navigateBack = useCallback(() => {
// If the action is categorize and there's no policies other than personal one, we simply call goBack(), i.e: dismiss the whole flow together
// We don't need to subscribe to policy_ collection as we only need to check on the latest collection value
if (action === CONST.IOU.ACTION.CATEGORIZE && PolicyUtils.hasNoPolicyOtherThanPersonalType()) {
Navigation.goBack();
return;
}
// If there is not a report attached to the IOU with a reportID, then the participants were manually selected and the user needs taken
// back to the participants step
if (!transaction?.participantsAutoAssigned) {
Expand Down
Loading