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 2025-01-18] [$250] Search - Workspace chat preview, flickers between last message and information message #53361

Open
4 of 8 tasks
IuliiaHerets opened this issue Dec 1, 2024 · 44 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production 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

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Dec 1, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.69-1
Reproducible in staging?: Y
Reproducible in production?: N
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y
Issue reported by: Applause Internal Team

Action Performed:

  1. Open the staging.new.expensify.com website.
  2. Tap on "Settings" and select "Workspaces"
  3. Open any workspace and tap on "Members"
  4. Tap on "Invite Member"
  5. Invite any member to workspace.
  6. Return to LHN.
  7. Open the workspace individual chat created for this invited member.
  8. Send any message on it.
  9. Tap on the search icon.
  10. Start writing a search related to this last chat.
  11. Verify that with every letter added on the search input, this chat preview keeps displaying the last sent message.

Expected Result:

The preview of the individual chat created for an invited workspace member, should keep displaying the last sent message when writing on the search input.

Actual Result:

Chat preview of individual chat created for an invited workspace member, flickers between the last sent message and the workspace information message with every letter added on the search input.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6681273_1733068550003.WS_Member_chat.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021863580183549143544
  • Upwork Job ID: 1863580183549143544
  • Last Price Increase: 2024-12-16
  • Automatic offers:
    • rojiphil | Reviewer | 105395423
Issue OwnerCurrent Issue Owner: @isabelastisser
@IuliiaHerets IuliiaHerets added DeployBlockerCash This issue or pull request should block deployment Bug Something is broken. Auto assigns a BugZero manager. labels Dec 1, 2024
Copy link

melvin-bot bot commented Dec 1, 2024

Triggered auto assignment to @isabelastisser (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 the Daily KSv2 label Dec 1, 2024
Copy link

melvin-bot bot commented Dec 1, 2024

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

Copy link

melvin-bot bot commented Dec 1, 2024

💬 A slack conversation has been started in #expensify-open-source

Copy link
Contributor

github-actions bot commented Dec 1, 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.

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Dec 1, 2024
@mountiny mountiny added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Dec 2, 2024
@mountiny
Copy link
Contributor

mountiny commented Dec 2, 2024

This is a minor ux issue, feels like the state is changing between optimistic offline and the response from the server

Demoted

@mountiny mountiny moved this to Bugs and Follow Up Issues in [#whatsnext] #expense Dec 2, 2024
@mountiny
Copy link
Contributor

mountiny commented Dec 2, 2024

cc @luacmartins @lakchote you might know the best about changes related to this area of code

@Beamanator Beamanator added the External Added to denote the issue can be worked on by a contributor label Dec 2, 2024
Copy link

melvin-bot bot commented Dec 2, 2024

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

@melvin-bot melvin-bot bot changed the title Search - Workspace chat preview, flickers between last message and information message [$250] Search - Workspace chat preview, flickers between last message and information message Dec 2, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 2, 2024
Copy link

melvin-bot bot commented Dec 2, 2024

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

@Beamanator
Copy link
Contributor

Demoting makes sense to me 👍 making this external since the flicker sounds like a UI-only bug

@bernhardoj
Copy link
Contributor

Proposal

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

Workspace chat subtitle text flickers when typing on search modal.

What is the root cause of that problem?

The flicker changes between the last message and the workspace name. When we get the option list subtitle, we mutate the original report object.

reportOption.alternateText = getAlternateText(reportOption, {showChatPreviewLine, forcePolicyNamePreview});

This report object comes from OptionsListContextProvider which shares the options list between multiple components. In our case, when we open the search page, there are 3 usages that calls getOptions, two of the usages pass forcePolicyNamePreview as true and the 3rd one passes forcePolicyNamePreview as false, and showChatPreviewLine as true.

if ((option.isPolicyExpenseChat ?? false) || isAdminRoom || isAnnounceRoom) {
return showChatPreviewLine && !forcePolicyNamePreview && formattedLastMessageText ? formattedLastMessageText : option.subtitle;
}

This happens after #53293 which adds the showChatPreviewLine to fix #53291. But from my testing, even if I remove the changes from that PR, the issue doesn't happen anymore. I'm not sure what causes that issue (53291), but the changes from PR (53293) add the showChatPreviewLine to the participantsAutocompleteList section, while the issue happens on the recent reports/chats section.

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

We can probably revert #53293, but I think we should avoid mutating the original object in the first place. To do that, we need to convert this into a const first.

reportOption.alternateText = getAlternateText(reportOption, {showChatPreviewLine, forcePolicyNamePreview});

const alternateText = getAlternateText(reportOption, {showChatPreviewLine, forcePolicyNamePreview});

And instead of using the reportOption, we need to clone the object first.

recentReportOptions.push(reportOption);
}
} else {
recentReportOptions.push(reportOption);
}

const newReportOption = {
    ...reportOption,
    alternateText,
}

We can do the same for this:

reportOption.isSelected = isReportSelected(reportOption, selectedOptions);
reportOption.isBold = shouldBoldTitleByDefault || shouldUseBoldText(reportOption);

reportOption.lastIOUCreationDate = lastIOUAction.lastModified;

But I think the reason we mutate it so we don't affect the performance from the cloning operation. If we don't want to do the cloning, we can do the hard way, that is by changing the item structure to be like this:

{
option: reportOption,
alternateText,
isSelected,
...
}

There will be a lot of reactors and it actually looks similar to this.

type SearchOption<T> = ReportUtils.OptionData & {
item: T;
};

@aldo-expensify
Copy link
Contributor

but I think we should avoid mutating the original object in the first place. To do that, we need to convert this into a const first.

I think these mutations are very prone to introducing hard to find bugs so they should be removed.

But I think the reason we mutate it so we don't affect the performance from the cloning operation.

I'm pretty sure we can avoid performance issues without introducing mutations. How many options are we processing here?

We can do the same for this:
reportOption.isSelected = isReportSelected(reportOption, selectedOptions);
reportOption.isBold = shouldBoldTitleByDefault || shouldUseBoldText(reportOption);

Yes, lets just avoid cloning the same object each time a key is changed :P

@luacmartins
Copy link
Contributor

I agree that we should remove the mutations.

I'm pretty sure we can avoid performance issues without introducing mutations. How many options are we processing here?

This function is used by the LHN as well, so we are processing the full LHN results for users. Not sure how large that data set is though.

@lakchote
Copy link
Contributor

If the current behavior is acceptable, then we can close this and wait until another unexpected issue caused by the mutation side-effect comes up.

This is not an acceptable behavior to have a flickering UI (bug starts happening at 0:43 in the video for those finding the issue).

We need to address this.

@bernhardoj
Copy link
Contributor

Oh, I don't mean the flickering behavior. I and @rojiphil can't see the flickering anymore, but the mutation still causes a different expected behavior shown from the code which I explained here.

Copy link

melvin-bot bot commented Dec 16, 2024

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

@rojiphil
Copy link
Contributor

I just mentioned that you can revert and see the behavior before that PR to prove the issue that is caused by mutating an object.

Ok. I will check this today and update.

@rojiphil
Copy link
Contributor

@bernhardoj Ok. So, we do not need to revert #53293 as the changes are needed to function properly. Also, we are not able to reproduce the flicker anymore. But I do agree that there is a possibility of mutation causing an issue at some point when there are multiple re-renders. And I also agree that we can avoid the mutation issue by creating a copy of reportOption and using it. LGTM.

@bernhardoj proposal LGTM.
🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Dec 18, 2024

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

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 19, 2024
Copy link

melvin-bot bot commented Dec 19, 2024

📣 @rojiphil 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@Beamanator
Copy link
Contributor

Love where we got with this issue 👍

Though I def believe we need to update the issue title & OP reproduction steps...

So it sounds like the new problem is here: #53361 (comment)

Can y'all confirm & let me know what reproduction steps y'all are following so I can update the OP?

@bernhardoj
Copy link
Contributor

Here are the steps:
Prerequisite:

  • have a workspace
  • have at least 1 other member
  • send a message at least once to the member workspace chat
  1. Open the search modal
  2. Search for the member workspace chat
  3. Observe that the subtitle shows the last message instead of the workspace name

NOTE: For user's own workspace chat, the workspace name is shown, so this issue only happens with member workspace chat

@bernhardoj
Copy link
Contributor

PR is ready

cc: @rojiphil

@mvtglobally
Copy link

Issue not reproducible during KI retests. (First week)

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jan 8, 2025
@melvin-bot melvin-bot bot changed the title [$250] Search - Workspace chat preview, flickers between last message and information message [HOLD for payment 2025-01-18] [$250] Search - Workspace chat preview, flickers between last message and information message Jan 11, 2025
Copy link

melvin-bot bot commented Jan 11, 2025

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 11, 2025
Copy link

melvin-bot bot commented Jan 11, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.83-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2025-01-18. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jan 11, 2025

@rojiphil @isabelastisser @rojiphil The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@garrettmknight garrettmknight moved this from Bugs and Follow Up Issues to Hold for Payment in [#whatsnext] #expense Jan 14, 2025
@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production 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
Projects
Status: Hold for Payment
Development

No branches or pull requests