Skip to content

Commit

Permalink
Merge pull request Expensify#46557 from gijoe0295/gijoe/46339
Browse files Browse the repository at this point in the history
[CP Staging] Fix: Not redirect to workspace chat when pay IOU with business account
  • Loading branch information
marcaaron authored Aug 2, 2024
2 parents b783854 + 161d11f commit 5005f59
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/components/KYCWall/BaseKYCWall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ function KYCWall({
Navigation.navigate(addDebitCardRoute);
} else if (paymentMethod === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT) {
if (iouReport && ReportUtils.isIOUReport(iouReport)) {
const policyID = Policy.createWorkspaceFromIOUPayment(iouReport);
const {policyID, workspaceChatReportID, reportPreviewReportActionID} = Policy.createWorkspaceFromIOUPayment(iouReport) ?? {};
if (workspaceChatReportID) {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(workspaceChatReportID, reportPreviewReportActionID));
}

// Navigate to the bank account set up flow for this specific policy
Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', policyID));
Expand Down
10 changes: 8 additions & 2 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ type NewCustomUnit = {
rates: Rate;
};

type WorkspaceFromIOUCreationData = {
policyID: string;
workspaceChatReportID: string;
reportPreviewReportActionID?: string;
};

const allPolicies: OnyxCollection<Policy> = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY,
Expand Down Expand Up @@ -2066,7 +2072,7 @@ function dismissAddedWithPrimaryLoginMessages(policyID: string) {
*
* @returns policyID of the workspace we have created
*/
function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): string | undefined {
function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): WorkspaceFromIOUCreationData | undefined {
// This flow only works for IOU reports
if (!ReportUtils.isIOUReportUsingReport(iouReport)) {
return;
Expand Down Expand Up @@ -2499,7 +2505,7 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): string | u

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

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

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

0 comments on commit 5005f59

Please sign in to comment.