Skip to content

[$250] [HOLD for payment 2024-07-10] Split bill - New group is created when splitting bill with the same users #40579

Closed

Description

@lanitochka17

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:

  1. Click on FAB > and create a split bill with two new users
  2. Click on FAB > and create another split bill the same two users you have created with on step one

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?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6454834_1713538523579.Screen_Recording_2024-04-19_at_5.53.41_in_the_afternoon.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01c9e84f7fad619cd5
  • Upwork Job ID: 1811859168529416327
  • Last Price Increase: 2024-07-12

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 19, 2024
  2. melvin-bot commented on Apr 19, 2024

    @melvin-bot

    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.

  3. lanitochka17 commented on Apr 19, 2024

    @lanitochka17
    Author

    @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

  4. FitseTLT commented on Apr 19, 2024

    @FitseTLT
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Split bill - New group is created when splitting bill with the same users

    What is the root cause of that problem?

    We are not checking if the group chat exists or not before creating here

    App/src/libs/actions/IOU.ts

    Lines 3104 to 3119 in 9b2c518

    if (participants.length > 1) {
    const splitChatReport = ReportUtils.buildOptimisticChatReport(
    allParticipantsAccountIDs,
    '',
    CONST.REPORT.CHAT_TYPE.GROUP,
    undefined,
    undefined,
    undefined,
    undefined,
    undefined,
    undefined,
    CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
    );
    return {existingSplitChatReport: null, splitChatReport};
    }

    What changes do you think we should make in order to solve the problem?

    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)
    

    What alternative solutions did you explore? (Optional)

    Optonally we can update this line of code

    App/src/libs/actions/IOU.ts

    Lines 3088 to 3092 in 9b2c518

    // If we do not have one locally then we will search for a chat with the same participants (only for 1:1 chats).
    const shouldGetOrCreateOneOneDM = participants.length < 2;
    if (!existingSplitChatReport && shouldGetOrCreateOneOneDM) {
    existingSplitChatReport = ReportUtils.getChatByParticipants(participantAccountIDs);
    }

    to

    if (!existingSplitChatReport) {
            existingSplitChatReport = ReportUtils.getChatByParticipants(
                [...participantAccountIDs, ...(participantAccountIDs.length > 1 ? [currentUserAccountID] : [])],
                undefined,
                participantAccountIDs.length > 1,
            );
        }
    
    
  5. shahinyan11 commented on Apr 19, 2024

    @shahinyan11
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Split bill - New group is created when splitting bill with the same users

    What is the root cause of that problem?

    New feature

    What changes do you think we should make in order to solve the problem?

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

    What alternative solutions did you explore? (Optional)

  6. FitseTLT commented on Apr 19, 2024

    @FitseTLT
    Contributor

    Updated Only to add a refactored code for same solution

  7. joekaufmanexpensify commented on Apr 19, 2024

    @joekaufmanexpensify
    Contributor

    I think this report is going to be obviated by a feature refactor we're working on. Discussing.

  8. joekaufmanexpensify commented on Apr 22, 2024

    @joekaufmanexpensify
    Contributor

    Not overdue

  9. joekaufmanexpensify commented on Apr 23, 2024

    @joekaufmanexpensify
    Contributor

    Bumped in slack

  10. joekaufmanexpensify commented on Apr 24, 2024

    @joekaufmanexpensify
    Contributor

    Bumped 1:1

  11. joekaufmanexpensify commented on Apr 25, 2024

    @joekaufmanexpensify
    Contributor

    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.

  12. 83 remaining items

  13. melvin-bot commented on Jul 12, 2024

    @melvin-bot
  14. changed the title [-][HOLD for payment 2024-07-10] Split bill - New group is created when splitting bill with the same users[/-] [+][$250] [HOLD for payment 2024-07-10] Split bill - New group is created when splitting bill with the same users[/+] on Jul 12, 2024
  15. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 12, 2024
  16. melvin-bot commented on Jul 12, 2024

    @melvin-bot

    Current assignee @Ollyws is eligible for the External assigner, not assigning anyone new.

  17. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 12, 2024
  18. joekaufmanexpensify commented on Jul 12, 2024

    @joekaufmanexpensify
    Contributor

    @FitseTLT offer sent for $250!

  19. joekaufmanexpensify commented on Jul 12, 2024

    @joekaufmanexpensify
    Contributor

    @Ollyws please request $250 via NewDot whenever you're ready!

  20. FitseTLT commented on Jul 12, 2024

    @FitseTLT
    Contributor

    @FitseTLT offer sent for $250!

    Accepted

  21. joekaufmanexpensify commented on Jul 12, 2024

    @joekaufmanexpensify
    Contributor

    @FitseTLT $250 sent and contract ended!

  22. joekaufmanexpensify commented on Jul 12, 2024

    @joekaufmanexpensify
    Contributor

    Upwork job closed.

  23. joekaufmanexpensify commented on Jul 12, 2024

    @joekaufmanexpensify
    Contributor

    Closing for now, as only thing left here is for @Ollyws to request their payment. Payment summary is here as FYI.

  24. joekaufmanexpensify commented on Jul 12, 2024

    @joekaufmanexpensify
    Contributor

    Thanks everyone!

  25. Ollyws commented on Jul 13, 2024

    @Ollyws
    Contributor

    Requested in ND.

  26. JmillsExpensify commented on Jul 16, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @Ollyws

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions