Skip to content

[hold for payment 2024-08-26] [$250] Split - Unable to split expense with workspace via FAB #47159

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: 9.0.18-7
Reproducible in staging?: Y
Reproducible in production?: N
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): applausetester+kh050806@applause.expensifail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to FAB > Split expense > Manual
  3. Enter amount > Next
  4. Select a workspace > Next
  5. Split the expense

Expected Result:

The expense is split in the workspace chat

Actual Result:

User is unable to split expense with workspace via FAB
App opens a report with RBR on LHN and the report shows infinite skeleton after splitting expense with workspace via FAB

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

Bug6566625_1723204349146.20240809_194957.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01fde995cf07525892
  • Upwork Job ID: 1821964572979581542
  • Last Price Increase: 2024-08-09
  • Automatic offers:
    • hoangzinh | Reviewer | 103497009
Issue OwnerCurrent Issue Owner: @hoangzinh

Activity

  1. added
    DeployBlockerCash
    DeployBlocker
    on Aug 9, 2024
  2. melvin-bot commented on Aug 9, 2024

    @melvin-bot

    Triggered auto assignment to @grgia (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  3. github-actions commented on Aug 9, 2024

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  4. lanitochka17 commented on Aug 9, 2024

    @lanitochka17
    Author

    We think that this bug might be related to #vip-split

  5. bernhardoj commented on Aug 9, 2024

    @bernhardoj
    Contributor

    Edited by proposal-police: This proposal was edited at {current_timestamp}.

    Proposal

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

    Can't split bill with workspace from FAB.

    What is the root cause of that problem?

    When we split bill with a workspace from FAB, we create a new workspace chat even though there is already a workspace chat. The reason we create a new workspace is because the existing chat report ID below is empty, so getOrCreateOptimisticSplitChatReport decide to create a new report.

    App/src/libs/actions/IOU.ts

    Lines 3812 to 3814 in db669c4

    function getOrCreateOptimisticSplitChatReport(existingSplitChatReportID: string, participants: Participant[], participantAccountIDs: number[], currentUserAccountID: number) {
    // The existing chat report could be passed as reportID or exist on the sole "participant" (in this case a report option)
    const existingChatReportID = existingSplitChatReportID ?? participants[0].reportID ?? '';

    Previously, the logic look like this:

    const existingChatReportID = existingSplitChatReportID || participants[0].reportID
    

    When we split bill from FAB, existingSplitChatReportID will be an empty string and if the participant is a workspace, then participants[0].reportID will contain the workspace reportID.

    But now, we use ?? which won't fallback to participants[0].reportID because existingSplitChatReportID is an empty string. The logic is updated by this commit.

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

    Based on the commit message, we don't want an undefined existingChatReportID which is possible if the participant is not a workspace.

    const existingChatReportID = '' || undefined => undefined
    

    That's why we fall back again to an empty string. But we shouldn't use ?? specifically for existingSplitChatReportID because it's an empty string and not undefined.

    const existingChatReportID = '' ?? {reportID} ?? '' => ''
    

    So, to fix this, we should change ?? to || back.

    const existingChatReportID = existingSplitChatReportID || participants[0].reportID || '';
    

    Btw, I think we should fall back to -1 or just let it be undefined again. If it's an empty string, then the report onyx key will be report_ which will fetch the whole report collection.

    let existingSplitChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${existingChatReportID}`];

    I think the reason we don't want the reportID to be undefined (report_undefined) is that sometimes the invalid report exists in the storage with error data, without a reportID.

    report_undefined: {
        errors: ...,
    }
    

    And because the report object is not undefined, the logic thinks that it found an existing report, even though it doesn't.

    App/src/libs/actions/IOU.ts

    Lines 3820 to 3828 in db669c4

    if (!existingSplitChatReport) {
    existingSplitChatReport = ReportUtils.getChatByParticipants(allParticipantsAccountIDs, undefined, participantAccountIDs.length > 1);
    }
    // We found an existing chat report we are done...
    if (existingSplitChatReport) {
    // Yes, these are the same, but give the caller a way to identify if we created a new report or not
    return {existingSplitChatReport, splitChatReport: existingSplitChatReport};
    }

    To fix this, we can check for the reportID to make sure the report object is valid.

    if (!existingSplitChatReport?.reportID) {
        existingSplitChatReport = ReportUtils.getChatByParticipants(allParticipantsAccountIDs, undefined, participantAccountIDs.length > 1);
    }
    
  6. added
    External
    on Aug 9, 2024
  7. changed the title [-]Split - Unable to split expense with workspace via FAB[/-] [+][$250] Split - Unable to split expense with workspace via FAB[/+] on Aug 9, 2024
  8. melvin-bot commented on Aug 9, 2024

    @melvin-bot
  9. added
    Help Wanted
    on Aug 9, 2024
  10. melvin-bot commented on Aug 9, 2024

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (External)

  11. 27 remaining items

  12. bernhardoj commented on Aug 13, 2024

    @bernhardoj
    Contributor

    PR is ready

    cc: @hoangzinh

  13. joekaufmanexpensify commented on Aug 19, 2024

    @joekaufmanexpensify
    Contributor

    PR merged!

  14. joekaufmanexpensify commented on Aug 26, 2024

    @joekaufmanexpensify
    Contributor

    Hmm, automation did not work here. This went out to prod over a week ago, so payment is due now. Will tackle payment in the next day or so!

  15. changed the title [-][$250] Split - Unable to split expense with workspace via FAB[/-] [+][hold for payment 2024-08-26] [$250] Split - Unable to split expense with workspace via FAB[/+] on Aug 26, 2024
  16. hoangzinh commented on Aug 27, 2024

    @hoangzinh
    Contributor

    BugZero Checklist:

    • The PR that introduced the bug has been identified. Link to the PR: Enable distance splits #42302
    • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: https://github.com/Expensify/App/pull/42302/files#r1732660564
    • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
    • Determine if we should create a regression test for this bug: 🚫 No, because it was a DB, I think we already have a regression test for this bug.
  17. joekaufmanexpensify commented on Aug 27, 2024

    @joekaufmanexpensify
    Contributor

    Sounds good. TY!

  18. joekaufmanexpensify commented on Aug 27, 2024

    @joekaufmanexpensify
    Contributor

    All set to issue payment here. We need to pay:

  19. joekaufmanexpensify commented on Aug 27, 2024

    @joekaufmanexpensify
    Contributor

    @hoangzinh $250 sent and contract ended!

  20. joekaufmanexpensify commented on Aug 27, 2024

    @joekaufmanexpensify
    Contributor

    Upwork job closed.

  21. joekaufmanexpensify commented on Aug 27, 2024

    @joekaufmanexpensify
    Contributor

    Closing as only thing left here is for @bernhardoj to request payment via NewDot!

  22. bernhardoj commented on Aug 27, 2024

    @bernhardoj
    Contributor

    Requested in ND.

  23. JmillsExpensify commented on Aug 28, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

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

Metadata

Metadata

Labels

BugDailyEngineeringExternalReviewing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions