Skip to content

Commit

Permalink
fix request money flow
Browse files Browse the repository at this point in the history
  • Loading branch information
BrtqKr committed Apr 9, 2024
1 parent 9e17db0 commit 1314c4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2256,7 +2256,7 @@ function updateDistanceRequest(
* Request money from another user
*/
function requestMoney(
report: OnyxTypes.Report,
report: OnyxEntry<OnyxTypes.Report>,
amount: number,
currency: string,
created: string,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function IOURequestStepConfirmation({

const requestMoney = useCallback(
(selectedParticipants: Participant[], trimmedComment: string, receiptObj?: Receipt, gpsPoints?: IOU.GpsPoint) => {
if (!report || !transaction) {
if (!transaction) {
return;
}

Expand Down

0 comments on commit 1314c4d

Please sign in to comment.