Skip to content

Commit

Permalink
Merge pull request #52610 from mkzie2/mkzie2-issue/52236
Browse files Browse the repository at this point in the history
Pass policy data to completePaymentOnboarding
  • Loading branch information
deetergp authored Nov 18, 2024
2 parents c24bc88 + 7549225 commit 5df1858
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/components/AddPaymentMethodMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ function AddPaymentMethodMenu({
text: translate('common.businessBankAccount'),
icon: Expensicons.Building,
onSelected: () => {
completePaymentOnboarding(CONST.PAYMENT_SELECTED.BBA);
onItemSelected(CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT);
},
},
Expand Down
4 changes: 3 additions & 1 deletion src/components/KYCWall/BaseKYCWall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {EmitterSubscription, GestureResponderEvent, View} from 'react-nativ
import {useOnyx} from 'react-native-onyx';
import AddPaymentMethodMenu from '@components/AddPaymentMethodMenu';
import * as BankAccounts from '@libs/actions/BankAccounts';
import {completePaymentOnboarding} from '@libs/actions/IOU';
import getClickedTargetLocation from '@libs/getClickedTargetLocation';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
Expand Down Expand Up @@ -108,7 +109,8 @@ function KYCWall({
Navigation.navigate(addDebitCardRoute);
} else if (paymentMethod === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT) {
if (iouReport && ReportUtils.isIOUReport(iouReport)) {
const {policyID, workspaceChatReportID, reportPreviewReportActionID} = Policy.createWorkspaceFromIOUPayment(iouReport) ?? {};
const {policyID, workspaceChatReportID, reportPreviewReportActionID, adminsChatReportID} = Policy.createWorkspaceFromIOUPayment(iouReport) ?? {};
completePaymentOnboarding(CONST.PAYMENT_SELECTED.BBA, adminsChatReportID, policyID);
if (workspaceChatReportID) {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(workspaceChatReportID, reportPreviewReportActionID));
}
Expand Down
7 changes: 3 additions & 4 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7364,7 +7364,7 @@ function cancelPayment(expenseReport: OnyxEntry<OnyxTypes.Report>, chatReport: O
*
* @param paymentSelected based on which we choose the onboarding choice and concierge message
*/
function completePaymentOnboarding(paymentSelected: ValueOf<typeof CONST.PAYMENT_SELECTED>) {
function completePaymentOnboarding(paymentSelected: ValueOf<typeof CONST.PAYMENT_SELECTED>, adminsChatReportID?: string, onboardingPolicyID?: string) {
const isInviteOnboardingComplete = introSelected?.isInviteOnboardingComplete ?? false;

if (isInviteOnboardingComplete || !introSelected?.choice || !introSelected?.inviteType) {
Expand All @@ -7390,15 +7390,14 @@ function completePaymentOnboarding(paymentSelected: ValueOf<typeof CONST.PAYMENT
CONST.ONBOARDING_MESSAGES[onboardingPurpose],
personalDetails?.firstName ?? '',
personalDetails?.lastName ?? '',
undefined,
undefined,
adminsChatReportID,
onboardingPolicyID,
paymentSelected,
undefined,
undefined,
true,
);
}

function payMoneyRequest(paymentType: PaymentMethodType, chatReport: OnyxTypes.Report, iouReport: OnyxEntry<OnyxTypes.Report>, full = true) {
if (chatReport.policyID && SubscriptionUtils.shouldRestrictUserBillableActions(chatReport.policyID)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(chatReport.policyID));
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ type WorkspaceFromIOUCreationData = {
policyID: string;
workspaceChatReportID: string;
reportPreviewReportActionID?: string;
adminsChatReportID: string;
};

const allPolicies: OnyxCollection<Policy> = {};
Expand Down Expand Up @@ -2563,7 +2564,7 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): WorkspaceF

API.write(WRITE_COMMANDS.CREATE_WORKSPACE_FROM_IOU_PAYMENT, params, {optimisticData, successData, failureData});

return {policyID, workspaceChatReportID: memberData.workspaceChatReportID, reportPreviewReportActionID: reportPreview?.reportActionID};
return {policyID, workspaceChatReportID: memberData.workspaceChatReportID, reportPreviewReportActionID: reportPreview?.reportActionID, adminsChatReportID};
}

function enablePolicyConnections(policyID: string, enabled: boolean) {
Expand Down

0 comments on commit 5df1858

Please sign in to comment.