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

Prevent additional requests on settled request reports #19033

Merged
merged 11 commits into from
May 17, 2023
18 changes: 17 additions & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ function getReportParticipantsTitle(logins) {
);
}

/**
* Checks if a report is an chat report.
*
* @param {Object} report
* @returns {Boolean}
*/
function isChatReport(report) {
return lodashGet(report, 'type') === CONST.REPORT.TYPE.CHAT;
}

/**
* Checks if a report is an Expense report.
*
Expand Down Expand Up @@ -2051,6 +2061,11 @@ function getMoneyRequestOptions(report, reportParticipants, betas) {
return [];
}

// Additional requests should be blocked for settled reports
if (isIOUReport(report) && !report.hasOutstandingIOU) {
mountiny marked this conversation as resolved.
Show resolved Hide resolved
return [];
}

// User created policy rooms and default rooms like #admins or #announce will always have the Split Bill option
// unless there are no participants at all (e.g. #admins room for a policy with only 1 admin)
// DM chats will have the Split Bill option only when there are at least 3 people in the chat.
Expand All @@ -2063,7 +2078,7 @@ function getMoneyRequestOptions(report, reportParticipants, betas) {
// Workspace chats should only see the Request money option, as "easy overages" is not available.
return [
...(canRequestMoney(report) ? [CONST.IOU.MONEY_REQUEST_TYPE.REQUEST] : []),
...(Permissions.canUseIOUSend(betas) && !isPolicyExpenseChat(report) ? [CONST.IOU.MONEY_REQUEST_TYPE.SEND] : []),
...(Permissions.canUseIOUSend(betas) && isChatReport(report) ? [CONST.IOU.MONEY_REQUEST_TYPE.SEND] : []),
mountiny marked this conversation as resolved.
Show resolved Hide resolved
];
}

Expand Down Expand Up @@ -2214,6 +2229,7 @@ export {
getAllPolicyReports,
getIOUReportActionMessage,
getDisplayNameForParticipant,
isChatReport,
isExpenseReport,
isIOUReport,
isTaskReport,
Expand Down