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

Fix split bill with one user from QAB shows not found page #39680

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
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
Loading