Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add participants back to buildOptimisticIOUReportAction #18711

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1145,13 +1145,14 @@ function getIOUReportActionMessage(type, total, comment, currency, paymentType =
* @param {Number} amount - IOU amount in cents.
* @param {String} currency
* @param {String} comment - User comment for the IOU.
* @param {Array} participants - An array with participants details.
* @param {String} transactionID
* @param {String} [paymentType] - Only required if the IOUReportAction type is 'pay'. Can be oneOf(elsewhere, payPal, Expensify).
* @param {String} [iouReportID] - Only required if the IOUReportActions type is oneOf(decline, cancel, pay). Generates a randomID as default.
* @param {Boolean} [isSettlingUp] - Whether we are settling up an IOU.
* @returns {Object}
*/
function buildOptimisticIOUReportAction(type, amount, currency, comment, transactionID, paymentType = '', iouReportID = '', isSettlingUp = false) {
function buildOptimisticIOUReportAction(type, amount, currency, comment, participants, transactionID, paymentType = '', iouReportID = '', isSettlingUp = false) {
const IOUReportID = iouReportID || generateReportID();
const parser = new ExpensiMark();
const commentText = getParsedComment(comment);
Expand Down
7 changes: 6 additions & 1 deletion src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ function requestMoney(report, amount, currency, payeeEmail, participant, comment
amount,
currency,
comment,
[participant],
optimisticTransaction.transactionID,
'',
moneyRequestReport.reportID,
Expand Down Expand Up @@ -285,7 +286,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, amount, comment

// Note: The created action must be optimistically generated before the IOU action so there's no chance that the created action appears after the IOU action in the chat
const groupCreatedReportAction = ReportUtils.buildOptimisticCreatedReportAction(currentUserEmail);
const groupIOUReportAction = ReportUtils.buildOptimisticIOUReportAction(CONST.IOU.REPORT_ACTION_TYPE.SPLIT, amount, currency, comment, groupTransaction.transactionID);
const groupIOUReportAction = ReportUtils.buildOptimisticIOUReportAction(CONST.IOU.REPORT_ACTION_TYPE.SPLIT, amount, currency, comment, participants, groupTransaction.transactionID);

groupChatReport.lastReadTime = DateUtils.getDBTime();
groupChatReport.lastMessageText = groupIOUReportAction.message[0].text;
Expand Down Expand Up @@ -424,6 +425,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, amount, comment
splitAmount,
currency,
comment,
[participant],
oneOnOneTransaction.transactionID,
'',
oneOnOneIOUReport.reportID,
Expand Down Expand Up @@ -650,6 +652,7 @@ function deleteMoneyRequest(chatReportID, iouReportID, moneyRequestAction, shoul
amount,
moneyRequestAction.originalMessage.currency,
Str.htmlDecode(moneyRequestAction.originalMessage.comment),
[],
transactionID,
'',
iouReportID,
Expand Down Expand Up @@ -822,6 +825,7 @@ function getSendMoneyParams(report, amount, currency, comment, paymentMethodType
amount,
currency,
comment,
[recipient],
optimisticTransaction.transactionID,
paymentMethodType,
optimisticIOUReport.reportID,
Expand Down Expand Up @@ -962,6 +966,7 @@ function getPayMoneyRequestParams(chatReport, iouReport, recipient, paymentMetho
iouReport.total,
iouReport.currency,
'',
[recipient],
optimisticTransaction.transactionID,
paymentMethodType,
iouReport.reportID,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/IOUUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const ownerEmail = '[email protected]';
const managerEmail = '[email protected]';

function createIOUReportAction(type, amount, currency, isOffline = false, IOUTransactionID = NumberUtils.rand64()) {
const moneyRequestAction = ReportUtils.buildOptimisticIOUReportAction(type, amount, currency, 'Test comment', IOUTransactionID, '', iouReport.reportID);
const moneyRequestAction = ReportUtils.buildOptimisticIOUReportAction(type, amount, currency, 'Test comment', [managerEmail], IOUTransactionID, '', iouReport.reportID);

// Default is to create requests online, if `isOffline` is not specified then we need to remove the pendingAction
if (!isOffline) {
Expand Down