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.53k stars 2.88k forks source link

[$250] Chat-Hidden is shown briefly on sending @new expensifail user #51186

Open izarutskaya opened 2 weeks ago

izarutskaya commented 2 weeks 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!


Version Number: V9. 0.51-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: "Hidden" is shown in Hybrid app, it doesn't disappear Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Issue reported by: Applause-Internal team

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Open self DM
  3. Enter @ and a new non existing expensifail account eg: @applausetester+1nonew@applause.expensifail.com
  4. Send the message

Expected Result:

Hidden must not be shown briefly on sending @new expensifail user.

Actual Result:

Hidden is shown briefly on sending @new expensifail user.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

https://github.com/user-attachments/assets/b01f5a2e-ad8e-4c8e-a2c5-6ae2a75f629a

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021849163258326584198
  • Upwork Job ID: 1849163258326584198
  • Last Price Increase: 2024-10-23
Issue OwnerCurrent Issue Owner: @rushatgabhane
melvin-bot[bot] commented 2 weeks ago

Triggered auto assignment to @johncschuster (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.

bernhardoj commented 2 weeks ago

Proposal

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

Hidden is shown briefly when mentioning a user that we never chat before.

What is the root cause of that problem?

When we send a mention a receive the BE response, it will merge a new data for the mention accountID and the personal details. If the accountID is available, we look for it in the personal details list. https://github.com/Expensify/App/blob/179d0f05e40744d08858778cf83aadf392334ad8/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx#L59-L64

However, the personal details list from the hook here is not updated yet. https://github.com/Expensify/App/blob/179d0f05e40744d08858778cf83aadf392334ad8/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx#L34

So, user will be undefined and because of that, the displayName is undefined too and we fallback to Hidden briefly. https://github.com/Expensify/App/blob/179d0f05e40744d08858778cf83aadf392334ad8/src/libs/PersonalDetailsUtils.ts#L78

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

We can check if both accountID and the personal details is available before using it. https://github.com/Expensify/App/blob/179d0f05e40744d08858778cf83aadf392334ad8/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx#L59-L60

if (!isEmpty(htmlAttribAccountID) && personalDetails[htmlAttribAccountID]) {
    const user = personalDetails[htmlAttribAccountID];

OR

We can use useOnyx hook instead which from my testing, updated the same time as the mention (action) accountID. https://github.com/Expensify/App/blob/179d0f05e40744d08858778cf83aadf392334ad8/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx#L34

OR do both

melvin-bot[bot] commented 2 weeks ago

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

melvin-bot[bot] commented 2 weeks ago

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

rushatgabhane commented 2 weeks ago

@bernhardoj's proposal LGTM we should do both, right?

🎀 👀 🎀

melvin-bot[bot] commented 2 weeks ago

Triggered auto assignment to @MariaHCD, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

MariaHCD commented 2 weeks ago

@bernhardoj's proposal looks good to me too but do is it necessary to do both?

rushatgabhane commented 2 weeks ago

if we don't do both, it might temporarily show hidden until the value is resolved. Right?

cc @bernhardoj

bernhardoj commented 2 weeks ago

Doing one of them is actually enough.

We can use useOnyx hook instead which from my testing, updated the same time as the mention (action) accountID.

I'm also suggesting doing both just in case the above isn't true anymore in the future. I think the 1st solution is the safest, but since replacing it with useOnyx is receiving the new value faster, I think there is no harm in doing both.

MariaHCD commented 2 weeks ago

Great, thanks for clarifying. Doing both sounds good to me.

bernhardoj commented 1 week ago

PR is ready

cc: @rushatgabhane