Closed lanitochka17 closed 1 month ago
Triggered auto assignment to @joekaufmanexpensify (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.
@joekaufmanexpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
Split bill - New group is created when splitting bill with the same users
We are not checking if the group chat exists or not before creating here https://github.com/Expensify/App/blob/9b2c5187e2203d83bba50bfa66936691788cbd18/src/libs/actions/IOU.ts#L3104-L3119
We should check if it already exists in onyx
if (participants.length > 1) {
const existing = ReportUtils.getChatByParticipants(allParticipantsAccountIDs, undefined, true) ?? null;
const splitChatReport =
!existing &&
ReportUtils.buildOptimisticChatReport(
allParticipantsAccountIDs,
'',
CONST.REPORT.CHAT_TYPE.GROUP,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
);
return {existingSplitChatReport: existing, splitChatReport: existing ?? splitChatReport};
}
currently getChatByParticipants
doesn't include group chats so we should update it to take a parameter includeGroupChats
and pass as true here
function getChatByParticipants(newParticipantList: number[], reports: OnyxCollection<Report> = allReports, includeGroupChats = false): OnyxEntry<Report> {
const sortedNewParticipantList = newParticipantList.sort();
return (
Object.values(reports ?? {}).find((report) => {
// If the report has been deleted, or there are no participants (like an empty #admins room) then skip it
if (
!report ||
report.participantAccountIDs?.length === 0 ||
isChatThread(report) ||
isTaskReport(report) ||
isMoneyRequestReport(report) ||
isChatRoom(report) ||
isPolicyExpenseChat(report) ||
(isGroupChat(report) && !includeGroupChats)
Optonally we can update this line of code https://github.com/Expensify/App/blob/9b2c5187e2203d83bba50bfa66936691788cbd18/src/libs/actions/IOU.ts#L3088-L3092 to
if (!existingSplitChatReport) {
existingSplitChatReport = ReportUtils.getChatByParticipants(
[...participantAccountIDs, ...(participantAccountIDs.length > 1 ? [currentUserAccountID] : [])],
undefined,
participantAccountIDs.length > 1,
);
}
Split bill - New group is created when splitting bill with the same users
New feature
Add below code above this line
const existingChatWithCurrentParticipants = ReportUtils.getChatByParticipants(participantAccountIDs)
if(!existingSplitChatReportID && !!existingChatWithCurrentParticipants){
existingSplitChatReportID = existingChatWithCurrentParticipants.reportID
}
Update this line as follows getChatByParticipants(participants)?.reportID || ''
I think this report is going to be obviated by a feature refactor we're working on. Discussing.
Not overdue
Bumped in slack
Bumped 1:1
Flagged again in Slack. This is definitely #vip-split related. But don't want to make external just yet since I feel like there is a solid chance we will close this.
@joekaufmanexpensify I'll take a look at the proposals tomorrow.
Great. TY!
@youssef-lr is going to look at proposals
Still pending
I will get to this this week
Great. TY!
@youssef-lr @joekaufmanexpensify this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
@youssef-lr will you have a chance to circle back to this soon? If you think we should definitely change this behavior, also happy to assign a C+ so they do preliminary review for you
@youssef-lr making this external for now so we can start to look at the proposals. When you have a sec, could you confirm if the solution in OP of the issue is what you wanted from the design doc?
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (External
)
I'm getting a different behaviour as described in the OP. Seems the split functionality has been moved to the FAB menu and following the steps from there results in:
@Ollyws yeah the split button did move to FAB, but I still get the same result when I try and reproduce. Splitting two expenses with the same two people creates a new group each time. Is that what you did to get that error?
Split bill always making new report despite existing group chat with same paritcipants.
In here:
the ReportUtils.getChatByParticipants
won't be called because shouldGetOrCreateOneOneDM
will be false if number of participant of splited bill more than 2 (including user that make split bills). So shouldGetOrCreateOneOneDM
will only be true if we split bills with exactly one other user.
Then ReportUtils.getChatByParticipants
won't be called and existingSplitChatReport will be undefined or null, then create new report in here:
and another problem if we disable shouldGetOrCreateOneOneDM check, and do getChatByParticipants
, the call to the function isn't including self/current account id. so it just pass other participant without ownself/current user (user that create split bill):
and another problem in getChatByParticipants
function:
it won't check on group report.
We need to add parameter currentUserAccountID
if we use ReportUtils.getChatByParticipants
and we need to investigate why the function won't search on groupChat:
if we can disable this check then we can use this function.
If we cannot disable this check (because of regression if we disable it) then we can create new function getGroupChatByParticipants
and use it in getOrCreateOptimisticSplitChatReport
function instead of ReportUtils.getChatByParticipants.
Also we need to investigate why:
shouldGetOrCreateOneOneDM
condition will be false if number split bill participant is more than 1.
I think we can disable this check but, further investigation on git blame will give some information .
Still discussing behavior here
I'm getting the behaviour mentioned here https://github.com/Expensify/App/issues/40579#issuecomment-2100014121 when splitting from the FAB menu, but if I split from the + menu in the chat it seems to create a new report action in the same chat:
@Ollyws the error is because the app create new report every time user splits expense from + FAB button -> Split expense
.
The server will returns error, because we must use existing group report with same split expense participant and we mustn't create new report.
If you can check my proposal, and here is the result:
I'm getting the behaviour mentioned here https://github.com/Expensify/App/issues/40579#issuecomment-2100014121 when splitting from the FAB menu, but if I split from the + menu in the chat it seems to create a new report action in the same chat:
Got it. I think the behavior specifically reported for this issue is for FAB. Though, I definitely agree this should work if from within the group too
Still pending further discussion
Investigating this one...
TY!
@Ollyws any update on this?
Apologies for the delay, will come to a conclusion tomorrow.
@FitseTLT's proposal LGTM. I don't see why we can't just update getChatByParticipants
to support group chats and remove the && shouldGetOrCreateOneOneDM
condition but we can address this in the PR.
🎀👀🎀 C+ reviewed
Current assignee @youssef-lr is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.
📣 @ShaheFS! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
@Ollyws Could you please give a feedback about my proposal ?
Pending sign off from @youssef-lr
@youssef-lr @Ollyws @joekaufmanexpensify this issue is now 4 weeks old, please consider:
Thanks!
@FitseTLT please share ETA for a PR
@youssef-lr, @Ollyws, @FitseTLT, @joekaufmanexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@FitseTLT is there an ETA for a PR here?
PR is ready
PR in review
PR awaiting review from @youssef-lr
bump for a final review @youssef-lr
on it today @FitseTLT
Still pending review from @youssef-lr
@youssef-lr Is this issue on hold now because of the change in project status?
@youssef-lr The conflict resolved and ready for your final review 👍
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 1.4.63-7 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4496719 Email or phone of affected tester (no customers): natnael.expensify+3@gmail.com Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
New group shouldn't be created, and the split bill should be added to the existing group
Actual Result:
A second, new group is created
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/Expensify/App/assets/78819774/b4527362-dcdf-4103-b3f0-a566fba97660
View all open jobs on GitHub
Issue Owner
Current Issue Owner: @Upwork Automation - Do Not Edit