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.5k stars 2.85k forks source link

Web - Chat - Chat not auto scrolled to the bottom when scrolling up and submitting expense #51492

Open lanitochka17 opened 1 day ago

lanitochka17 commented 1 day 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: 9.0.54-0 Reproducible in staging?: Y Reproducible in production?: Y 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?/tests/view/5136024&group_by=cases:section_id&group_order=asc&group_id=306202 Issue reported by: Applause - Internal Team

Action Performed:

  1. Open the staging.new.expensify.com website
  2. Open any chat with large history of messages
  3. Tap on "+" and select "Submit Expense"
  4. Complete the expense creation flow
  5. Delete the just created expense
  6. Scroll to the top of the chat
  7. Tap on "+" and select "Submit Expense"
  8. Complete the expense creation flow
  9. Once redirected to the chat, verify you are redirected to the bottom, to the new created expense

Expected Result:

When scrolling up the chat and submitting an expense, the user should be navigated to the bottom again, to the new created expense

Actual Result:

The chat is not auto scrolled to the bottom, when submitting an expense while scrolled up in the conversation, if another expense was deleted before in the same chat

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/user-attachments/assets/23583abf-0e51-4465-86f3-7fb5c258c2b7

View all open jobs on GitHub

melvin-bot[bot] commented 1 day ago

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

FitseTLT commented 1 day ago

Proposal

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

Web - Chat - Chat not auto scrolled to the bottom when scrolling up and submitting expense

What is the root cause of that problem?

When the expense is deleted from the chat report the lastVisibleActionCreated timestamp of the chat report should be updated to the last visible action's created timestamp but the BE is not updating it so here https://github.com/Expensify/App/blob/a86ee35a6c9706d8acb35202acb4cdaa1cc769e7/src/pages/home/report/ReportActionsList.tsx#L345-L352 scrollToBottom will fail(early returns) because hasNewestReportActionRef will be false because the lastVisibleActionCreated is pointing to the created timestamp of the deleted ReportPreview action which is not visible.

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

Ideally this should be fixed in BE as I discussed it ^. But we can also fix it in FE as the report actions deleted are not removed from sortedReportActions list we can change this https://github.com/Expensify/App/blob/a86ee35a6c9706d8acb35202acb4cdaa1cc769e7/src/pages/home/report/ReportActionsList.tsx#L286

    const hasNewestReportAction = sortedVisibleReportActions.at(0)?.created === lastVisibleActionCreated || sortedReportActions.at(0)?.created === lastVisibleActionCreated;

What alternative solutions did you explore? (Optional)