From 1314c4d8c4670580e1415b2f31d40b17b185f86c Mon Sep 17 00:00:00 2001 From: BrtqKr Date: Tue, 9 Apr 2024 22:31:40 +0200 Subject: [PATCH] fix request money flow --- src/libs/actions/IOU.ts | 12 +++++++----- .../iou/request/step/IOURequestStepConfirmation.tsx | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 8ca752a182df..c75a5fa7a7b4 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -2256,7 +2256,7 @@ function updateDistanceRequest( * Request money from another user */ function requestMoney( - report: OnyxTypes.Report, + report: OnyxEntry, amount: number, currency: string, created: string, @@ -2278,8 +2278,8 @@ function requestMoney( ) { // If the report is iou or expense report, we should get the linked chat report to be passed to the getMoneyRequestInformation function const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); - const currentChatReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report; - const moneyRequestReportID = isMoneyRequestReport ? report.reportID : ''; + const currentChatReport = isMoneyRequestReport ? ReportUtils.getReport(report?.chatReportID) : report; + const moneyRequestReportID = isMoneyRequestReport ? report?.reportID : ''; const currentCreated = DateUtils.enrichMoneyRequestTimestamp(created); const { payerAccountID, @@ -2314,7 +2314,7 @@ function requestMoney( payeeEmail, moneyRequestReportID, ); - const activeReportID = isMoneyRequestReport ? report.reportID : chatReport.reportID; + const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport.reportID; const parameters: RequestMoneyParams = { debtorEmail: payerEmail, @@ -2347,7 +2347,9 @@ function requestMoney( API.write(WRITE_COMMANDS.REQUEST_MONEY, parameters, onyxData); resetMoneyRequestInfo(); Navigation.dismissModal(activeReportID); - Report.notifyNewAction(activeReportID, payeeAccountID); + if (activeReportID) { + Report.notifyNewAction(activeReportID, payeeAccountID); + } } /** diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 5a9dd7343ae2..d20a576d279e 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -174,7 +174,7 @@ function IOURequestStepConfirmation({ const requestMoney = useCallback( (selectedParticipants: Participant[], trimmedComment: string, receiptObj?: Receipt, gpsPoints?: IOU.GpsPoint) => { - if (!report || !transaction) { + if (!transaction) { return; }