Skip to content

[Due for payment 2025-09-16] [HOLD on new PR] [$250] [BACK BUTTON] Back Button on Report Detail Page Resets Scroll Position on Reports List #66751

Closed

Description

@m-natarajan

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.1.84-4
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @dannymcclain
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Open the Reports page
  2. Scroll down the list and select a report that's not near the top
  3. After viewing the report, click the back button in the top-left corner

Expected Result:

The user should be returned to the same scroll position on the Reports page where they were before opening the report.

Actual Result:

The Reports page scrolls all the way to the top, and the user loses their place in the list.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop
Platforms Tested: On which of our officially supported platforms was this issue tested:
  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
CleanShot.2025-07-18.at.11.09.28.mp4
Recording.1433.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021948728734052183015
  • Upwork Job ID: 1948728734052183015
  • Last Price Increase: 2025-08-08
  • Automatic offers:
    • huult | Contributor | 108404009
Issue OwnerCurrent Issue Owner: @twisterdotcom

Activity

  1. added
    ImprovementItem broken or needs improvement.
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 18, 2025
  2. melvin-bot commented on Jul 18, 2025

    @melvin-bot

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

  3. thelullabyy commented on Jul 19, 2025

    @thelullabyy
    Contributor

    Proposal

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

    The Reports page scrolls all the way to the top, and the user loses their place in the list.

    What is the root cause of that problem?

    What is the root cause of that problem?

    The Search list component is unmounted when navigating away. Upon remounting, it does not restore the previous scroll position because there is no logic in place to preserve or restore the scroll offset.
    See https://reactnavigation.org/docs/stack-navigator/#detachinactivescreens

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

    1. Add logic to save and get the scroll offset:
        const listRef = useRef<FlashList<SearchListItem>>(null);
        const {saveScrollOffset, getScrollOffset} = useContext(ScrollOffsetContext);
        const route = useRoute();
        const scrollToSavePosition = useCallback(() => {
            const offset = getScrollOffset(route);
    
            if (!(offset && listRef.current)) {
                return;
            }
    
            // We need to use requestAnimationFrame to make sure it will scroll properly on iOS.
            requestAnimationFrame(() => {
                if (!(offset && listRef.current)) {
                    return;
                }
                listRef.current.scrollToOffset({offset}); // Can use animated here if needed
            });
        }, [getScrollOffset, route]);
    
        const scrollOffset = getScrollOffset(route);
    
    1. Update onScroll and onLayout function to use the above functions:

    onScroll={onScroll}

                    onScroll={(e) => {
                        saveScrollOffset(route, e.nativeEvent.contentOffset.y);
                        onScroll?.(e);
                    }}
    

    onLayout={onLayout}

                    onLayout={(e)=>{
                        scrollToSavePosition()
                        onLayout?.(e)
                    }}
    
    1. Update logic to clear the scroll offset storage:
      if (!scrollOffsetKeysOfExistingScreens.includes(key)) {
                if (!scrollOffsetKeysOfExistingScreens.includes(key) && !(key === `${SCREENS.SEARCH.ROOT}-global`)) {
    

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

    NA

    What alternative solutions did you explore? (Optional)

  4. melvin-bot commented on Jul 22, 2025

    @melvin-bot

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

  5. melvin-bot commented on Jul 24, 2025

    @melvin-bot

    @twisterdotcom Eep! 4 days overdue now. Issues have feelings too...

  6. twisterdotcom commented on Jul 25, 2025

    @twisterdotcom
    Contributor

    Wow yes, this is annoying. I thought this was to do with he browser back button which is a whole other kettle of fish, but this seems like something we should solve for sure.

  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 25, 2025
  8. changed the title [-]Back Button on Report Detail Page Resets Scroll Position on Reports List[/-] [+][$250] Back Button on Report Detail Page Resets Scroll Position on Reports List[/+] on Jul 25, 2025
  9. melvin-bot commented on Jul 25, 2025

    @melvin-bot
  10. 56 remaining items

  11. changed the title [-][HOLD on new PR] [$250] Back Button on Report Detail Page Resets Scroll Position on Reports List[/-] [+][Due for payment 2025-09-16] [HOLD on new PR] [$250] Back Button on Report Detail Page Resets Scroll Position on Reports List[/+] on Sep 9, 2025
  12. melvin-bot commented on Sep 9, 2025

    @melvin-bot

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

  13. melvin-bot commented on Sep 9, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.2-8 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-09-16. 🎊

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

  14. melvin-bot commented on Sep 9, 2025

    @melvin-bot

    @akinwale @twisterdotcom 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]

  15. changed the title [-][Due for payment 2025-09-16] [HOLD on new PR] [$250] Back Button on Report Detail Page Resets Scroll Position on Reports List[/-] [+][Due for payment 2025-09-16] [HOLD on new PR] [$250] [BACK BUTTON] Back Button on Report Detail Page Resets Scroll Position on Reports List[/+] on Sep 11, 2025
  16. twisterdotcom commented on Sep 11, 2025

    @twisterdotcom
    Contributor

    Hello assignees. We came to the conclusion in #57969 that the back buttons in the app behave inconsistently and in a way that we don't think is ideal, but that fixing the issue is a potentially high cost, low reward situation. We are going to start tracking these issues and attempt to find a way and somebody who can help solve this problem heuristically across the app.

    I have HELD a lot of issues related to the "back button" but any that are currently Reviewing or Due for payment I have not held. If you believe your issue shouldn't be linked or HELD, comment with the explanation and I will review and unlike/remove the hold. Thank you!

  17. akinwale commented on Sep 17, 2025

    @akinwale
    Contributor

    BugZero Checklist:

    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [@akinwale] 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: N/A

    • [@akinwale] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: N/A

    • [@akinwale] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/548891

    Regression Test Proposal

    Test:

    1. Launch Expensify.
    2. Open the Reports tab.
    3. Scroll down and select a report that is not near the top of the list.
    4. Click on the report to view the report, and then click the Back button at the top-left corner.
    5. Verify that the user is returned to the same scroll position on the Reports screen before the report was viewed.

    Do we agree 👍 or 👎?

  18. huult commented on Sep 18, 2025

    @huult
    Contributor

    @twisterdotcom Just a friendly reminder about the pending payment 😊

  19. twisterdotcom commented on Sep 18, 2025

    @twisterdotcom
    Contributor

    Payment Summary:

  20. garrettmknight commented on Sep 18, 2025

    @garrettmknight
    Contributor

    $250 approved for @akinwale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorImprovementItem broken or needs improvement.WeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions