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-06-20] [HOLD for payment 2024-06-18] CRITICAL: [UX Reliability] [$1000] Chat - Chat does not scroll down when sending messages #40724

Closed
2 of 6 tasks
kbecciv opened this issue Apr 22, 2024 · 123 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

@kbecciv
Copy link

kbecciv commented Apr 22, 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: 1.4.64-0
Reproducible in staging?: y
Reproducible in production?: y
Issue reported by: Applause - Internal Team

Action Performed:

  1. Launch New Expensify app.
  2. Go to empty chat.
  3. Send a text.

Expected Result:

The chat view will scroll down to show the latest message.

Actual Result:

The chat view does not scroll down to show the latest message.

Workaround:

n/a

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

Bug6457776_1713809495909.RPReplay_Final1713809407.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016dcc2d8605cc9198
  • Upwork Job ID: 1782503029072748544
  • Last Price Increase: 2024-05-30
  • Automatic offers:
    • DylanDylann | Reviewer | 0
    • ikevin127 | Contributor | 0
    • nkdengineer | Contributor | 102574769
Issue OwnerCurrent Issue Owner: @anmurali
@kbecciv kbecciv added the DeployBlockerCash This issue or pull request should block deployment label Apr 22, 2024
Copy link

melvin-bot bot commented Apr 22, 2024

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

@kbecciv
Copy link
Author

kbecciv commented Apr 22, 2024

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

Copy link
Contributor

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

@mountiny mountiny added the External Added to denote the issue can be worked on by a contributor label Apr 22, 2024
Copy link

melvin-bot bot commented Apr 22, 2024

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

@melvin-bot melvin-bot bot changed the title Chat - Chat does not scroll down when sending messages [$250] Chat - Chat does not scroll down when sending messages Apr 22, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 22, 2024
Copy link

melvin-bot bot commented Apr 22, 2024

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

@mountiny
Copy link
Contributor

Looking for proposals

@luacmartins
Copy link
Contributor

Gonna look into this one

@mountiny
Copy link
Contributor

it might be related to #40547

@josh-prof
Copy link

I found the issue, and looking for possible solutions.

@luacmartins
Copy link
Contributor

Cool, let us know what you find @climax0916

@josh-prof
Copy link

When adding comments, shouldEnableAutoScroll turns to False so ReportActionsList doesn't scroll to the latest message.

const shouldEnableAutoScroll = hasNewestReportAction && (!reportActionID || !isNavigatingToLinkedMessage);
return (
<>
<ReportActionsList
report={report}
transactionThreadReport={transactionThreadReport}
reportActions={reportActions}
parentReportAction={parentReportAction}
parentReportActionForTransactionThread={parentReportActionForTransactionThread}
onLayout={recordTimeToMeasureItemLayout}
sortedReportActions={reportActionsToDisplay}
mostRecentIOUReportActionID={mostRecentIOUReportActionID}
loadOlderChats={loadOlderChats}
loadNewerChats={loadNewerChats}
isLoadingInitialReportActions={isLoadingInitialReportActions}
isLoadingOlderReportActions={isLoadingOlderReportActions}
isLoadingNewerReportActions={isLoadingNewerReportActions}
listID={listID}
onContentSizeChange={onContentSizeChange}
shouldEnableAutoScrollToTopThreshold={shouldEnableAutoScroll}
/>
<UserTypingEventListener report={report} />
<PopoverReactionList ref={reactionListRef} />
</>
);

@josh-prof
Copy link

@luacmartins Am I right?

@luacmartins
Copy link
Contributor

Why does it become false?

@josh-prof
Copy link

When adding new transactions, this API.write() function is called:

API.write(commandName, parameters, {
optimisticData,
successData,
failureData,
});

Then, Onyx.update(optimisticData) is called for update Onyx storage:

Log.info('Called API write', false, {command, ...apiCommandParameters});
const {optimisticData, ...onyxDataWithoutOptimisticData} = onyxData;
// Optimistically update Onyx
if (optimisticData) {
Onyx.update(optimisticData);
}

After that, render again because of Onyx storage changed. But, here hasNewestReportAction will be False:

const hasNewestReportAction = reportActions[0]?.created === report.lastVisibleActionCreated || reportActions[0]?.created === transactionThreadReport?.lastVisibleActionCreated;

Because of this, the scroll doesn't down to the latest message.

@DylanDylann
Copy link
Contributor

I think this issue have the same RCA with #40664

@ikevin127
Copy link
Contributor

ikevin127 commented Apr 23, 2024

Proposal

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

Chat does not scroll down when sending messages.

What is the root cause of that problem?

Two things which both cause our issue:

1.

Whenever we start a new chat there's this new action which I assume was introduced by BE recently: an additional new ADDCOMMENT action comes in right after the "CREATED" action, which is an automated message (one in the middle):

Screenshot 2024-04-23 at 05 43 37

This addition causes hasNewestReportAction to return false since sortedReportActions?.[0] is now the automated ADDCOMMENT action (first in sortedReportActions) instead of the user posted message like it used to be -> meaning that the the automated message's created date is not equal to the report's lastVisibleActionCreated date because the lastVisibleActionCreated date equals to the sortedReportActions?.[1] at index 1 (user's comment) hence the condition returns false.

This makes it such that the scrollToBottomForCurrentUserAction returns early because of the !hasNewestReportActionRef.current check being true.

2.

Due to recent new architecture being enabled, it looks like the native specific scrollToBottom function does not trigger the scrolling anymore even though it's called and this happens because there's a few things going on when we post a comment from JS's point of view and because scrollToBottom gets called while the stack is ongoing (not cleared yet), the function does not perform it's logic as expected.

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

We have a two part solution to address both parts of the RCA:

1.

The first part of the RCA was already handled by PR #40286, specifically this line where we make sure we don't early return when the user posts their first comment when the first action is a whisper (automated comment).

2.
In order to have the scrollToBottom function work as expected, similar to what I proposed in issue #38855 and was selected / approved -> use deferred execution via requestAnimationFrame to wrap the contents of the function like so:

    const scrollToBottom = useCallback(() => {
        requestAnimationFrame(() => {
            if (!flatListRef?.current) {
                return;
            }
    
            setScrollPosition({offset: 0});
    
            flatListRef.current?.scrollToOffset({animated: false, offset: 0});
        });
    }, [flatListRef, setScrollPosition]);

This ensures that the code within scrollToBottom will be executed on the next tick, essentially telling the JavaScript runtime to execute this code after the current call stack has cleared.

Here's a test branch of the solution: test/40724 and it's diff.

Videos (before / after)

iOS: Native
Before After
before.mov
after.mov

@mountiny
Copy link
Contributor

Based on the previous comments this seems like it might not be a deploy blocker as if its related to the new architecture, that has already been deployed to production

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jun 11, 2024
@melvin-bot melvin-bot bot changed the title CRITICAL: [UX Reliability] [$1000] Chat - Chat does not scroll down when sending messages [HOLD for payment 2024-06-18] CRITICAL: [UX Reliability] [$1000] Chat - Chat does not scroll down when sending messages Jun 11, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 11, 2024
Copy link

melvin-bot bot commented Jun 11, 2024

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

Copy link

melvin-bot bot commented Jun 11, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.81-11 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 2024-06-18. 🎊

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

Copy link

melvin-bot bot commented Jun 11, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@parasharrajat] The PR that introduced the bug has been identified. Link to the PR:
  • [@parasharrajat] 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:
  • [@parasharrajat] 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:
  • [@parasharrajat] Determine if we should create a regression test for this bug.
  • [@parasharrajat] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@anmurali] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jun 13, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-06-18] CRITICAL: [UX Reliability] [$1000] Chat - Chat does not scroll down when sending messages [HOLD for payment 2024-06-20] [HOLD for payment 2024-06-18] CRITICAL: [UX Reliability] [$1000] Chat - Chat does not scroll down when sending messages Jun 13, 2024
Copy link

melvin-bot bot commented Jun 13, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.82-4 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 2024-06-20. 🎊

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

Copy link

melvin-bot bot commented Jun 13, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@parasharrajat] The PR that introduced the bug has been identified. Link to the PR:
  • [@parasharrajat] 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:
  • [@parasharrajat] 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:
  • [@parasharrajat] Determine if we should create a regression test for this bug.
  • [@parasharrajat] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@anmurali] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 18, 2024
@parasharrajat
Copy link
Member

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

Regression Test Steps

For attachments, text messages, For whispers.
  1. Open a DM chat or WS chat that has long history chat
  2. Send an attachments
  3. Verify that the chat scrolls to the bottom
  4. Scroll to the top and send a message
  5. Verify that the chat scrolls to the bottom
  6. Create a split expense
  7. Verify that the chat scrolls to the bottom
For IOU reports, For IOU previews.
  1. Open a IOU report
  2. Send a message
  3. Verify that the chat scrolls to the bottom
  4. Submit an expense
  5. Verify that the chat scrolls to the bottom
  6. For thread replies
  7. Open a thread with long history chat
  8. Scroll to the top and send a message
  9. Verify that the chat scrolls to the bottom

Do you agree 👍 or 👎 ?

@luacmartins
Copy link
Contributor

IMO we can skip TC in this case given that's such an obvious issue that many people would report it. I'm not too passionate about it though so also ok adding it.

@melvin-bot melvin-bot bot added the Overdue label Jun 20, 2024
@anmurali
Copy link

anmurali commented Jun 21, 2024

Final payment summary

@melvin-bot melvin-bot bot removed the Overdue label Jun 21, 2024
@parasharrajat
Copy link
Member

Payment requested as per #40724 (comment)

@JmillsExpensify
Copy link

$1,000 approved for @parasharrajat

@m-natarajan
Copy link

@m-natarajan m-natarajan reopened this Jul 9, 2024
@melvin-bot melvin-bot bot added the Overdue label Jul 9, 2024
@anmurali
Copy link

Closing this again as per that thread we agreed to create a new issue.

@melvin-bot melvin-bot bot removed the Overdue label Jul 10, 2024
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
Development

No branches or pull requests