Skip to content

Commit

Permalink
Move the navigation action out of Policy action
Browse files Browse the repository at this point in the history
  • Loading branch information
mountiny committed Nov 9, 2023
1 parent c9a9ec4 commit 23dda79
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/components/KYCWall/BaseKYCWall.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as Policy from '@userActions/Policy';
import * as Wallet from '@userActions/Wallet';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import {defaultProps, propTypes} from './kycWallPropTypes';

// This component allows us to block various actions by forcing the user to first add a default payment method and successfully make it through our Know Your Customer flow
Expand Down Expand Up @@ -100,7 +101,10 @@ class KYCWall extends React.Component {
Navigation.navigate(this.props.addDebitCardRoute);
} else if (paymentMethod === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT) {
if (ReportUtils.isIOUReport(this.props.iouReport)) {
Policy.createWorkspaceFromIOUPayment(this.props.iouReport);
const policyID = Policy.createWorkspaceFromIOUPayment(this.props.iouReport);

// Navigate to the bank account set up flow for this specific policy
Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', policyID));
return;
}
Navigation.navigate(this.props.addBankAccountRoute);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function isDeletedParentAction(reportAction: OnyxEntry<ReportAction>): boolean {
}

function isReversedTransaction(reportAction: OnyxEntry<ReportAction>) {
return (reportAction?.message?.[0].isReversedTransaction ?? false) && (reportAction?.childVisibleActionCount ?? 0) > 0;
return (reportAction?.message?.[0]?.isReversedTransaction ?? false) && (reportAction?.childVisibleActionCount ?? 0) > 0;
}

function isPendingRemove(reportAction: OnyxEntry<ReportAction>): boolean {
Expand Down
13 changes: 9 additions & 4 deletions src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';

const allPolicies = {};
Onyx.connect({
Expand Down Expand Up @@ -1463,6 +1461,14 @@ function buildOptimisticPolicyRecentlyUsedCategories(policyID, category) {
return lodashUnion([category], policyRecentlyUsedCategories);
}

/**
* This flow is used for bottom up flow converting IOU report to an expense report. When user takes this action,
* we create a Collect type workspace when the person taking the action becomes an owner and an admin, while we
* add a new member to the workspace as an employee and convert the IOU report passed as a param into an expense report.
*
* @param {Object} iouReport
* @returns {String} policyID of the workspace we have created
*/
function createWorkspaceFromIOUPayment(iouReport) {
// This flow only works for IOU reports
if (!ReportUtils.isIOUReport(iouReport)) {
Expand Down Expand Up @@ -1816,8 +1822,7 @@ function createWorkspaceFromIOUPayment(iouReport) {
{optimisticData, successData, failureData},
);

// Navigate to the bank account set up flow for this specific policy
Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', policyID));
return policyID;
}

export {
Expand Down
3 changes: 0 additions & 3 deletions src/pages/home/report/ReportActionItemMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ function ReportActionItemMessage(props) {
iouMessage = ReportUtils.getReportPreviewMessage(ReportUtils.getReport(iouReportID), props.action);
}
}
<<<<<<< HEAD
=======

const isApprovedOrSubmittedReportAction = _.contains([CONST.REPORT.ACTIONS.TYPE.APPROVED, CONST.REPORT.ACTIONS.TYPE.SUBMITTED], props.action.actionName);

Expand Down Expand Up @@ -85,7 +83,6 @@ function ReportActionItemMessage(props) {
return shouldWrapInText ? <Text style={styles.ltr}>{reportActionItemFragments}</Text> : reportActionItemFragments;
};

>>>>>>> main
return (
<View style={[styles.chatItemMessage, !props.displayAsGroup && isAttachment ? styles.mt2 : {}, ...props.style]}>
{!props.isHidden ? (
Expand Down

0 comments on commit 23dda79

Please sign in to comment.