Skip to content

Commit

Permalink
Merge pull request #27133 from dukenv0307/fix/27075
Browse files Browse the repository at this point in the history
Add ability to request money from iou and expense report
  • Loading branch information
mountiny authored Sep 13, 2023
2 parents 56ceee5 + ed3215f commit ee4eef8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3109,8 +3109,8 @@ function getMoneyRequestOptions(report, reportParticipants, betas) {
return [];
}

// Additional requests should be blocked for money request reports
if (isMoneyRequestReport(report)) {
// Additional requests should be blocked for money request reports if it is approved or reimbursed
if (isMoneyRequestReport(report) && (isReportApproved(report) || isSettled(report.reportID))) {
return [];
}

Expand Down
15 changes: 10 additions & 5 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,11 @@ function createDistanceRequest(report, participant, comment, created, transactio
* @param {String} [category]
*/
function requestMoney(report, amount, currency, created, merchant, payeeEmail, payeeAccountID, participant, comment, receipt = undefined, category = undefined) {
// 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 {payerEmail, iouReport, chatReport, transaction, iouAction, createdChatReportActionID, createdIOUReportActionID, reportPreviewAction, onyxData} = getMoneyRequestInformation(
report,
currentChatReport,
participant,
comment,
amount,
Expand Down Expand Up @@ -636,7 +639,7 @@ function requestMoney(report, amount, currency, created, merchant, payeeEmail, p
onyxData,
);
resetMoneyRequestInfo();
Navigation.dismissModal(chatReport.reportID);
Navigation.dismissModal(isMoneyRequestReport ? report.reportID : chatReport.reportID);
Report.notifyNewAction(chatReport.reportID, payeeAccountID);
}

Expand Down Expand Up @@ -1925,12 +1928,14 @@ function navigateToNextPage(iou, iouType, reportID, report) {

// If a request is initiated on a report, skip the participants selection step and navigate to the confirmation page.
if (report.reportID) {
// If the report is iou or expense report, we should get the chat report to set participant for request money
const chatReport = ReportUtils.isMoneyRequestReport(report) ? ReportUtils.getReport(report.chatReportID) : report;
// Reinitialize the participants when the money request ID in Onyx does not match the ID from params
if (_.isEmpty(iou.participants) || shouldReset) {
const currentUserAccountID = currentUserPersonalDetails.accountID;
const participants = ReportUtils.isPolicyExpenseChat(report)
? [{reportID: report.reportID, isPolicyExpenseChat: true, selected: true}]
: _.chain(report.participantAccountIDs)
const participants = ReportUtils.isPolicyExpenseChat(chatReport)
? [{reportID: chatReport.reportID, isPolicyExpenseChat: true, selected: true}]
: _.chain(chatReport.participantAccountIDs)
.filter((accountID) => currentUserAccountID !== accountID)
.map((accountID) => ({accountID, selected: true}))
.value();
Expand Down

0 comments on commit ee4eef8

Please sign in to comment.