Skip to content

Commit

Permalink
pass policy data to completePaymentOnboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
mkzie2 committed Nov 15, 2024
1 parent a6f1348 commit 6012f8f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 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
12 changes: 10 additions & 2 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7346,7 +7346,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) {
Expand All @@ -7367,7 +7367,15 @@ function completePaymentOnboarding(paymentSelected: ValueOf<typeof CONST.PAYMENT
onboardingPurpose = CONST.ONBOARDING_CHOICES.CHAT_SPLIT;
}

Report.completeOnboarding(onboardingPurpose, CONST.ONBOARDING_MESSAGES[onboardingPurpose], personalDetails?.firstName ?? '', personalDetails?.lastName ?? '', paymentSelected);
Report.completeOnboarding(
onboardingPurpose,
CONST.ONBOARDING_MESSAGES[onboardingPurpose],
personalDetails?.firstName ?? '',
personalDetails?.lastName ?? '',
adminsChatReportID,
onboardingPolicyID,
paymentSelected,
);
}

function payMoneyRequest(paymentType: PaymentMethodType, chatReport: OnyxTypes.Report, iouReport: OnyxEntry<OnyxTypes.Report>, full = true) {
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 6012f8f

Please sign in to comment.