[$250] Task – Task creator avatar appears briefly on top of chat when create task with non-existing #47151
Description
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?: 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/4836876
Email or phone of affected tester (no customers): applausetester+jp_e_category_2@applause.expensifail.com
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team
Action Performed:
- Go to https://staging.new.expensify.com/
- Log in
- Click on FAB and Assign task
- Enter title
- Click on Assignee and select non-existing user
- Click on Confirm the task
Expected Result:
Task assignee avatar present on the top of the chat
Actual Result:
Task creator avatar appears briefly on the top of the chat
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
Bug6566324_1723174921955.Task_non-ex.mp4
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~016ea999111b3bbb3c
- Upwork Job ID: 1822945464965222378
- Last Price Increase: 2024-08-19
Issue Owner
Current Issue Owner: @c3024Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
melvin-bot commentedon Aug 9, 2024
Triggered auto assignment to @bfitzexpensify (
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.izarutskaya commentedon Aug 9, 2024
We think this issue might be related to the #vip-vsb
bfitzexpensify commentedon Aug 12, 2024
Minor bug. Will send external to see if it's easy to resolve, but I think this is the type of thing we could also close.
melvin-bot commentedon Aug 12, 2024
Job added to Upwork: https://www.upwork.com/jobs/~016ea999111b3bbb3c
[-] Task – Task creator avatar appears briefly on top of chat when create task with non-existing[/-][+][$250] Task – Task creator avatar appears briefly on top of chat when create task with non-existing[/+]melvin-bot commentedon Aug 12, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @c3024 (
External)20 remaining items
marcaaron commentedon Aug 21, 2024
This sounds better IMO, but might not be valuable enough to spend time on right now.
c3024 commentedon Aug 22, 2024
Actually, it's the other way around. Here's the flow:
A task is created, and the
participantsfield in the report contains the optimistic assignee ID and the current user ID.The backend returns a response with the report containing the
participantsfield with the non-optimistic (real) assignee ID and the current user ID. This is then merged into Onyx.App/src/libs/actions/OnyxUpdates.ts
Line 37 in 685bb4c
Now, the
participantsfield has three participants. The logic here:App/src/libs/ReportUtils.ts
Lines 2351 to 2359 in ddec3e7
checks if it's a one-on-one chat by excluding the current user ID and checking the number of participants in the report:
App/src/libs/ReportUtils.ts
Lines 1599 to 1613 in ddec3e7
When there are three participants in the report, this check fails. As a result, the current user ID is not excluded, and all three avatars are briefly shown.
Then, the
successData:App/src/libs/ReportUtils.ts
Line 6780 in ddec3e7
is merged into Onyx:
App/src/libs/actions/OnyxUpdates.ts
Lines 38 to 42 in 685bb4c
This removes the optimistic assignee ID, and only one avatar is shown correctly because the one-on-one chat check now succeeds.
I agree. I think, generally and not just in this specific case, that unless the
successDatais a large object that would be prohibitive to send over the network, it might be better to merge thesuccessDataon the backend and include it in the response, where practicable.@dominictb correct me if I am wrong.
dominictb commentedon Aug 22, 2024
I'll send the video in a bit.
marcaaron commentedon Aug 22, 2024
Ok, got it, thanks for the explanation @c3024.
It still sounds like a possible "root cause" is that we are not merging together these two updates, but merging in the server data first then the
successDataat some delay? If we were to say, collapse the server data +successDatainto one single update first then this "flash" of inaccurate stuff would not happen?Hmm I think perhaps the server should just be responsible for the part of
successDatathat might cause a problem like this - but not all thesuccessDatain a general sense since issues like this are rare.Given how our system works and applies updates the current behavior makes sense. There is no differentiation between optimistic and actual data. But exposing that detail to the frontend might not be the answer to me. So, I'd think we'd either:
optimisticAccountIDand then have the server set it tonullin the same update (and really anytime a "real" accountID is created we should also be doing this in the server)OR
OR
accountIDcan be client generated.Honestly, since everything ends up looking how it should look I'm not sure if we should be doing the proposed solution. Going to ask what the internal team thinks about this one.
kaushiktd commentedon Aug 23, 2024
@marcaaron, when I pulled the code, the steps you mentioned didn’t work as expected. The assigned task isn't showing up in the top menu.
screen-capture.webm
c3024 commentedon Aug 23, 2024
@marcaaron
Yes, that is the root cause. As I mentioned here:
the comment suggests merging response data and
successDatasuccessively. I did not dig deeper into why it is required. I assumed it must be something important and felt that the frontend hack was acceptable since it had already been used elsewhere.All three solutions you suggested are indeed more ideal than filtering the optimistic ID on the frontend.
Yes, the three avatars appear for a very brief time, and sometimes it happens so quickly that it’s not perceptible at all. We can leave this as it is and close this issue. Perhaps this brainstorming will be useful if we encounter a situation where the gap between updates actually causes a significant UI/UX issue.
dominictb commentedon Aug 23, 2024
It is in my local machine and possibly your local machine but not in the OP's machine, or any user's browser. It is not guaranteed at all.
It is in fact the correct and recommended design. The response data should be merged first, acknowledging that we have received data from the server before we move forward with the
successData. For example in this case, if we applysuccessDataandserverDatasimultaneously , the optimistic data clean up could happen first before the BE-returned data kick in, and that could lead to situation in the participant list:But the ideal UX in this way, should be the change of optimistic participant record -> BE-returned participant record without any disappearing gap.
I don't feel like it. BE should never be responsible for cleaning up optimistic data in the FE, because BE will never have the full context of what is optimistic data by generated by FE, and BE should not need to know that. FE should be the one responsible for cleaning up optimistic data and other related optimistic UX (including hiding/disable optimistic data), making sure that the UI makes sense to the end user. This is why I advocate for FE strategy in other issue and this issue as well.
c3024 commentedon Aug 23, 2024
I did not mean that we can apply them simultaneously. I understand that we should have the backend response before doing anything with
successData. I meant that I have not checked the difficulties of merging the (successful) response data and success data together first and then merging this merged object into Onyx.dominictb commentedon Aug 23, 2024
Thinking about it, since we have this PR Expensify/react-native-onyx#490 merged, can we reliably do
updateHandler(...response.onyxData, ...successData)? Because now we ensure that every individual operation passed inOnyx.updateis applied reliably.jacobkim9881 commentedon Aug 23, 2024
@c3024 Let me know you if I found a solution.
jacobkim9881 commentedon Aug 23, 2024
Exactly the report having the issuable merging was made just after "GetMissingOnyxMessages" request. Here is the process when after creating a task:
melvin-bot commentedon Aug 23, 2024
@marcaaron @bfitzexpensify @c3024 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
marcaaron commentedon Aug 23, 2024
Can someone maybe explain why there is a delay for some users and other times not? This seems to point even further to a problem at some lower level with Onyx. My expectation is that even if we are applying the server data followed by the
successDatathat this would not be a noticeable event.Anyways, I think this pretty low priority. Maybe we should just close it out @bfitzexpensify ?
marcaaron commentedon Aug 23, 2024
Actually I'm going to close and if there is enough compelling evidence to point to we can reopen.