Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.56k stars 2.9k forks source link

[$1000] Dev: Cannot split money in DM group chat #22440

Closed kbecciv closed 1 year ago

kbecciv commented 1 year ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Create new group chat with existing contacts
  2. Click + on composer and Split bill
  3. Enter amount and click Next
  4. Click Split xxx button

Expected Result:

Money is split correctly

Actual Result:

hows console error

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Version Number: Dev 1.3.37-6 Reproducible in staging?: n/a Reproducible in production?: n/a If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation

https://github.com/Expensify/App/assets/93399543/98b81d9b-68a8-4c59-be1f-9691bdc4fa7c

Expensify/Expensify Issue URL: Issue reported by: @0xmiroslav Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1688715731926879

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~011a656ab6a105b57b
  • Upwork Job ID: 1678431703910395904
  • Last Price Increase: 2023-08-04
melvin-bot[bot] commented 1 year ago

Triggered auto assignment to @isabelastisser (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

melvin-bot[bot] commented 1 year ago

Bug0 Triage Checklist (Main S/O)

chiragxarora commented 1 year ago

PROPOSAL

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

Cannot split money in DM group chat (where there is a non logged in user)

What is the root cause of that problem?

Root cause of the issue is in IOU.js, createSplitsAndOnyxData method where it fails at the line

https://github.com/Expensify/App/blob/58f663a2ff05bd06be3dd9a438cad8ad86d3ac68/src/libs/actions/IOU.js#L465-L465

It does so because if the group has a member who is not an actual logged in user, his login field is undefined which causes the failure of the arrayToString method since it does not expect an undefined. As a result we fail to get formatted participants list which we use in the system message in the chat report after splitting the bill

Upon further investigation, I found the main root cause to be the optimistic data being used when we split bill from FAB, and while splitting the bill from chat report, we are using the data stored in onyx.

See for the same account, we have different data upon spliting bill from different places

WhatsApp Image 2023-07-08 at 13 39 57 WhatsApp Image 2023-07-08 at 13 40 48

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

Simple fix:

We can get their login field from some other key, and for this we already have alternateText that we can use. Or can use accountID to fetch it via PersonalDetailsUtils's method getPersonalDetailsByIDs

Otherwise, expected behavior considering all the cases should be known, then we can decide how to approach this

What alternative solutions did you explore? (Optional)

we can also restrict split bill functionality for the logged in users only

isabelastisser commented 1 year ago

I'm unable to reproduce this.

0xmiros commented 1 year ago

@isabelastisser please check slack link. This bug is being actively researched on.

melvin-bot[bot] commented 1 year ago

Job added to Upwork: https://www.upwork.com/jobs/~011a656ab6a105b57b

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

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

fedirjh commented 1 year ago

I was not able to reproduce this issue.

chiragxarora commented 1 year ago

Refer the slack thread @fedirjh

isabelastisser commented 1 year ago

Discussing the next steps in Slack.

isabelastisser commented 1 year ago

We can't reproduce this. @chiragxarora, if you can help with reproducible steps (as per Carlo's suggestion in the Slack discussion), please follow up on this issue.

I am closing this for now.

0xmiros commented 1 year ago

@isabelastisser please create new group with any random users (mix of existing contacts and non-existing contacts)

0xmiros commented 1 year ago

Also test with new account

kbecciv commented 1 year ago

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690404444868009 Posting a clear reproduction steps:

  1. Create a group with 2 unknown users
  2. Create Split bill in this group

https://github.com/Expensify/App/assets/93399543/9478c33e-3c48-45f8-a2e0-a58503a5024c

melvin-bot[bot] commented 1 year ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

melvin-bot[bot] commented 1 year ago

@isabelastisser @fedirjh this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!

fedirjh commented 1 year ago

Awaiting on proposals.

isabelastisser commented 1 year ago

Still waiting for proposals.

StevenKKC commented 1 year ago

Proposal

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

Cannot split money in DM group chat.

What is the root cause of that problem?

The root cause is that new user does not have login field. This is expected if another user has never interaction with you and is the purpose of login => accountID migration.

After create a group chat with new users, BE responds personalDetailsList as below. Screenshot 2023-08-01 054241

If split money success, BE responds as below. Screenshot 2023-08-01 054307

In MoneyRequestConfirmPage page, participants will be retrieved as below. https://github.com/Expensify/App/blob/89dfb7788ed3a533da5d5e2c9e55335028570d82/src/pages/iou/steps/MoneyRequestConfirmPage.js#L71 https://github.com/Expensify/App/blob/89dfb7788ed3a533da5d5e2c9e55335028570d82/src/libs/OptionsListUtils.js#L207-L234 So the login field of participants is set to undefined.

In these line, because login field is undefined, so the console error will be shown, and cannot split money. https://github.com/Expensify/App/blob/89dfb7788ed3a533da5d5e2c9e55335028570d82/src/libs/actions/IOU.js#L452 https://github.com/Expensify/App/blob/89dfb7788ed3a533da5d5e2c9e55335028570d82/src/libs/actions/IOU.js#L574

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

We can set login field of participants as below, because displayName of new user is just email address. After split money success, the login of new user will be set correctly.

Result

ice_video_20230801-064755.webm

StevenKKC commented 1 year ago

After create a group chat with new users, duplicated contacts is stored in Onyx. This will be fixed in https://github.com/Expensify/App/issues/21706

isabelastisser commented 1 year ago

@fedirjh it seems like we only have one proposal above, can you please review it and let me know if we should move forward with that? Thanks!

fedirjh commented 1 year ago

@chiragxarora @StevenKKC The root cause needs further investigation. The participants are generated optimistically, so we should have the required data for making the split request. The issue doesn’t seem to be reproducible in offline mode, so I think the problem is in the backend.

Upon further investigation, I found the main root cause to be the optimistic data being used when we split bill from FAB, and while splitting the bill from chat report, we are using the data stored in onyx.

@chiragxarora Can you please elaborate more?


As for the solution, I think both solutions are not valid, for some logins we don't have any data about the emails, alternateText or displayName will not always hold the email, it will hold the display name and fallback to email: here is an example, second email is a valid account with display name:

Screenshot 2023-08-02 at 4 56 08 PM Screenshot 2023-08-02 at 4 57 47 PM

Finally, I think a backend changes may be required to fix this case. I found that we still use emails in the SplitBill command, and that maybe was missed during the accountID refactor ? cc @puneetlath @Beamanator

https://github.com/Expensify/App/blob/92117c52af956e7f45c4374dbf69d06632af7601/src/libs/actions/IOU.js#L670

isabelastisser commented 1 year ago

We don't have a proposal yet.

puneetlath commented 1 year ago

I think this can probably be closed as a dupe of https://github.com/Expensify/App/issues/21268

melvin-bot[bot] commented 1 year ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

fedirjh commented 1 year ago

@isabelastisser Seems it will be covered in https://github.com/Expensify/App/issues/21268. Let's hold / close ?

melvin-bot[bot] commented 1 year ago

@isabelastisser @fedirjh this issue is now 4 weeks old and preventing us from maintaining WAQ, can you:

Thanks!

melvin-bot[bot] commented 1 year ago

Current assignee @fedirjh is eligible for the Internal assigner, not assigning anyone new.

isabelastisser commented 1 year ago

Based on the comments below, I will close this.

https://github.com/Expensify/App/issues/22440#issuecomment-1664673279

https://github.com/Expensify/App/issues/22440#issuecomment-1665866448

isabelastisser commented 1 year ago

Payment summary:

Issue reported by: @0xmiroslav $250

I will process the payment in Upwork now.

0xmiros commented 1 year ago

@isabelastisser can you please hold my payment until further notice? I am working on some stuff due to recent measurements in my region. Thanks

0xmiros commented 1 year ago

@isabelastisser sorry for inconvenience. I am now ready for payment as discussed in email.

isabelastisser commented 1 year ago

@0xmiroslav I resent the offer in Upwork now, please accept it and I will process the payment. Thanks!

0xmiros commented 1 year ago

@isabelastisser sorry if you haven't checked email, can you please check https://expensify.slack.com/archives/C01SKUP7QR0/p1692226249296529?thread_ts=1691559426.466079&cid=C01SKUP7QR0?

isabelastisser commented 1 year ago

Hey @0xmiroslav, thanks for the heads up! I reviewed the discussion now and re-sent the proposal to Volodymyr L.

All set.