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

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

Closed
6 tasks done
lanitochka17 opened this issue Aug 9, 2024 · 29 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 9, 2024

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
@lanitochka17 lanitochka17 added DeployBlockerCash This issue or pull request should block deployment DeployBlocker Indicates it should block deploying the API labels Aug 9, 2024
Copy link

melvin-bot bot commented Aug 9, 2024

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

Copy link
Contributor

github-actions bot commented Aug 9, 2024

👋 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.

@lanitochka17
Copy link
Author

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

@bernhardoj
Copy link
Contributor

bernhardoj commented Aug 9, 2024

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);
}

@grgia grgia added the External Added to denote the issue can be worked on by a contributor label Aug 9, 2024
@melvin-bot melvin-bot bot changed the title Split - Unable to split expense with workspace via FAB [$250] Split - Unable to split expense with workspace via FAB Aug 9, 2024
Copy link

melvin-bot bot commented Aug 9, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01fde995cf07525892

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 9, 2024
Copy link

melvin-bot bot commented Aug 9, 2024

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

@grgia
Copy link
Contributor

grgia commented Aug 9, 2024

@hoangzinh could you assess the proposal, I think we can assign @bernhardoj

@grgia grgia removed the DeployBlockerCash This issue or pull request should block deployment label Aug 9, 2024
@thienlnam
Copy link
Contributor

@grgia Did you mean to remove the App blocker? Looks like this is a FE issue

@thienlnam thienlnam added DeployBlockerCash This issue or pull request should block deployment and removed DeployBlocker Indicates it should block deploying the API labels Aug 9, 2024
Copy link

melvin-bot bot commented Aug 9, 2024

Current assignee @grgia is eligible for the DeployBlockerCash assigner, not assigning anyone new.

Copy link
Contributor

github-actions bot commented Aug 9, 2024

👋 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.

@hoangzinh
Copy link
Contributor

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.

@bernhardoj because we're getting the report from an array, therefore if it's an empty string, it won't return any data, will it?

App/src/libs/actions/IOU.ts

Lines 3816 to 3817 in 93dc1c9

// Check if the report is available locally if we do have one
let existingSplitChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${existingChatReportID}`];

Btw, I think it's safer if we check existingChatReportID exists before retrieving existingSplitChatReport from array. What do you think?

@bernhardoj
Copy link
Contributor

because we're getting the report from an array

ReportConnection.getAllReports() doesn't return an array, it's an object.

Btw, I think it's safer if we check existingChatReportID exists before retrieving existingSplitChatReport from array. What do you think?

That's a good idea. I remember we did that before, but it was changed in this PR

@hoangzinh
Copy link
Contributor

hoangzinh commented Aug 12, 2024

Oh my bad, it's an object.

I remember we did that before, but it was changed in this PR

It appears that there is a commit 1443b26 from that PR to fix disabling Eslint comment. Btw, because it's a DB, I'm happy with either way

@bernhardoj's proposal #47159 (comment) looks good to me

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Aug 12, 2024

Current assignee @grgia is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@Beamanator
Copy link
Contributor

@bernhardoj if you could please make this fix a priority, that would be great!

@Beamanator Beamanator added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Aug 12, 2024
@Beamanator
Copy link
Contributor

Actually if this was really caused by #42302, this shouldn't be a blocker anymore since #42302 is now in prod 😅

@Beamanator Beamanator added the Bug Something is broken. Auto assigns a BugZero manager. label Aug 12, 2024
Copy link

melvin-bot bot commented Aug 12, 2024

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.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Aug 13, 2024
@bernhardoj
Copy link
Contributor

PR is ready

cc: @hoangzinh

@joekaufmanexpensify
Copy link
Contributor

PR merged!

@joekaufmanexpensify
Copy link
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!

@joekaufmanexpensify joekaufmanexpensify 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 Aug 26, 2024
@hoangzinh hoangzinh mentioned this issue Aug 27, 2024
58 tasks
@hoangzinh
Copy link
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.

@joekaufmanexpensify joekaufmanexpensify added Daily KSv2 and removed Weekly KSv2 labels Aug 27, 2024
@joekaufmanexpensify
Copy link
Contributor

Sounds good. TY!

@joekaufmanexpensify
Copy link
Contributor

joekaufmanexpensify commented Aug 27, 2024

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

@joekaufmanexpensify
Copy link
Contributor

@hoangzinh $250 sent and contract ended!

@joekaufmanexpensify
Copy link
Contributor

Upwork job closed.

@joekaufmanexpensify
Copy link
Contributor

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

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

8 participants