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

[$250] 53978-Chat-New message button disappears when navigating back the the main chat from a thread #54093

Open
5 of 8 tasks
mitarachim opened this issue Dec 13, 2024 · 16 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Overdue

Comments

@mitarachim
Copy link

mitarachim commented Dec 13, 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.75-5
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/cases/view/2661784
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Device used: MacBook Air Sonoma 14.1 Chrome, iPhone 15 iOS 18.1.1 Safari
App Component: Chat Report View

Action Performed:

  1. Navigate to staging.new.expensify.com and log in
  2. Open a chat with a long conversation history
  3. Mark the latest message as unread
  4. Scroll up the chat history and verify, that New message button is shown
  5. Go into any sub-thread (Create one if needed)
  6. Go back to the main chat
  7. Verify that New message button is still presented

Expected Result:

New message button still shown in the chat with the message marked as unread after returning from a subthread.

Actual Result:

New message button disappears, and the message marked as unread is not shown as new after returning from a subthread.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6692821_1734047464876.message_is_not_marked_as_new.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021867422219524271281
  • Upwork Job ID: 1867422219524271281
  • Last Price Increase: 2024-12-27
Issue OwnerCurrent Issue Owner: @alitoshmatov
@mitarachim mitarachim added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 13, 2024
Copy link

melvin-bot bot commented Dec 13, 2024

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

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

melvin-bot bot commented Dec 13, 2024

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

@melvin-bot melvin-bot bot changed the title 53978-Chat-New message button disappears when navigating back the the main chat from a thread [$250] 53978-Chat-New message button disappears when navigating back the the main chat from a thread Dec 13, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 13, 2024
Copy link

melvin-bot bot commented Dec 13, 2024

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

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

mkzie2 commented Dec 13, 2024

Proposal

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

New message button disappears, and the message marked as unread is not shown as new after returning from a subthread.

What is the root cause of that problem?

We call goBack with shouldEnforceFallback as true so it always navigates to the fallback route here. Then a new report screen is added to the navigation stack which causes OpenReport API is called and the report is marked as read

Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(parentReportID, parentReportActionID), true);

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

We should not pass shouldEnforceFallback as true. And we should use Navigation.isNavigationReady() to wait for the navigation action here

Navigation.isNavigationReady().then(() => {
    Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(parentReportID, parentReportActionID));
});

Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(parentReportID, parentReportActionID), true);

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA (It's a UI issue)

What alternative solutions did you explore? (Optional)

Screen.Recording.2024-12-13.at.12.57.39.mov

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@FitseTLT
Copy link
Contributor

FitseTLT commented Dec 13, 2024

Edited by proposal-police: This proposal was edited at 2024-12-13 21:19:09 UTC.

Proposal

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

Chat-New message button disappears when navigating back the the main chat from a thread

What is the root cause of that problem?

When navigating back from the thread we are linking to the parent report action and when the link has the report action id we want to position that specific report action as the bottom most report action to achieve that we slice report action list to the linkedReportActionIndex here on first render

if (isFirstLinkedActionRender.current) {
return combinedReportActions.slice(indexOfLinkedAction);
}

after positioning we set firstRenderRef to false so we will now add the report actions below the linked action to the list
const paginationSize = getInitialPaginationSize;
return combinedReportActions.slice(Math.max(indexOfLinkedAction - paginationSize, 0));

With this background, the root cause of our current issue is we ignore unread markers if the new message is coming from the current user here
const shouldIgnoreUnreadForCurrentUserMessage = !prevUnreadMarkerReportActionID.current && isFromCurrentUser && (isNewMessage || isPreviouslyOptimistic);

this was introduced by #51113 to fix an issue of showing unread marker for message created by the current user but to determine that the message is a new message we check that the unread message was not part of previous visible report action list
const isNewMessage = !prevSortedVisibleReportActionsObjects[message.reportActionID];

So in our case when we come back from the thread it is assuming that the report action that we have marked as unread before going to the child thread is a new message added by the current user. Why? because as I have explained above when as we are linking to a report action on first render we chop off all report actions below the linked action (to position it to the bottom as explained above) Therefore, isNewMessage will be true hence the message will be ignored from being marked and New message buttons too don't appear if there are no unread report actions so it doesn't appear 👍
if (scrollingVerticalOffset.current > VERTICAL_OFFSET_THRESHOLD && !isFloatingMessageCounterVisible && !!unreadMarkerReportActionID) {
setIsFloatingMessageCounterVisible(true);
}

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

The fact that the message doesn't exist in prevSortedVisibleReportActionsObjects doesn't always mean that the message is a new message added because it could also be due to the report action not included in the previous report action but was included in the list now when the user scrolls down and newer actions are being loaded. Therefore, the correct way to determine it is a new message is that its created timestamp is now equal to the report lastVisibleActionCreated but unequal to the previous report lastVisibleActionCreated. So:

    const prevLastVisibleActionCreated = usePrevious(report.lastVisibleActionCreated);

        const isNewMessage = report.lastVisibleActionCreated === message.created && prevLastVisibleActionCreated !== message.created;
            const isNewMessage = report.lastVisibleActionCreated === message.created && prevLastVisibleActionCreated !== message.created;

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

What alternative solutions did you explore? (Optional)

Copy link

melvin-bot bot commented Dec 14, 2024

📣 @banjaminlee! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

Copy link

melvin-bot bot commented Dec 16, 2024

@kadiealexander, @alitoshmatov Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Dec 16, 2024
Copy link

melvin-bot bot commented Dec 18, 2024

@kadiealexander, @alitoshmatov Huh... This is 4 days overdue. Who can take care of this?

@mkzie2
Copy link
Contributor

mkzie2 commented Dec 18, 2024

@alitoshmatov Any update here?

Copy link

melvin-bot bot commented Dec 20, 2024

@kadiealexander, @alitoshmatov 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

Copy link

melvin-bot bot commented Dec 20, 2024

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

@alitoshmatov
Copy link
Contributor

Sorry, I have a lot on my plate. Will ask to other C reassignment

@melvin-bot melvin-bot bot removed the Overdue label Dec 22, 2024
@allroundexperts
Copy link
Contributor

Taking over. Please assign to me @kadiealexander

@alitoshmatov alitoshmatov removed their assignment Dec 22, 2024
@melvin-bot melvin-bot bot added the Overdue label Dec 25, 2024
Copy link

melvin-bot bot commented Dec 26, 2024

@kadiealexander Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

Copy link

melvin-bot bot commented Dec 27, 2024

@kadiealexander 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!

Copy link

melvin-bot bot commented Dec 27, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Overdue
Projects
Status: Bugs and Follow Up Issues
Development

No branches or pull requests

7 participants
@allroundexperts @FitseTLT @kadiealexander @alitoshmatov @mkzie2 @mitarachim and others