Skip to content

Commit

Permalink
Merge pull request #39680 from bernhardoj/fix/39406-include-split-bil…
Browse files Browse the repository at this point in the history
…l-option-on-dm

Fix split bill with one user from QAB shows not found page
  • Loading branch information
NikkiWines authored Apr 5, 2024
2 parents d3c60f6 + 1a9a2de commit f150229
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4808,6 +4808,7 @@ function canRequestMoney(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, o
* - Send option should show for:
* - DMs
* - Split options should show for:
* - DMs
* - chat/ policy rooms with more than 1 participants
* - groups chats with 3 and more participants
* - corporate workspace chats
Expand All @@ -4833,7 +4834,6 @@ function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Pol

const otherParticipants = reportParticipants.filter((accountID) => currentUserPersonalDetails?.accountID !== accountID);
const hasSingleOtherParticipantInReport = otherParticipants.length === 1;
const hasMultipleOtherParticipants = otherParticipants.length > 1;
let options: Array<ValueOf<typeof CONST.IOU.TYPE>> = [];

if (isSelfDM(report)) {
Expand All @@ -4842,11 +4842,11 @@ function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Pol

// User created policy rooms and default rooms like #admins or #announce will always have the Split Bill option
// unless there are no other 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 2 other people in the chat.
// DM chats will have the Split Bill option.
// Your own workspace chats will have the split bill option.
if (
(isChatRoom(report) && otherParticipants.length > 0) ||
(isDM(report) && hasMultipleOtherParticipants) ||
(isDM(report) && otherParticipants.length > 0) ||
(isGroupChat(report) && otherParticipants.length > 0) ||
(isPolicyExpenseChat(report) && report?.isOwnPolicyExpenseChat)
) {
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ describe('ReportUtils', () => {
type: CONST.REPORT.TYPE.CHAT,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]);
expect(moneyRequestOptions.length).toBe(2);
expect(moneyRequestOptions.length).toBe(3);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SEND)).toBe(true);
});
Expand Down

0 comments on commit f150229

Please sign in to comment.