Skip to content

[Due for Payment 2026-04-09][$250] Expenses – Bottom comments are briefly displayed when switching between chats #75269

Closed

Description

@lanitochka17

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.2.59-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://test-management.browserstack.com/projects/2219752/folder/13176676/test-cases/41237298
Email or phone of affected tester (no customers): sintayewhaylu01@gmail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Navigate to staging.new.expensfy.com
  2. Create an expense in Workspace chat
  3. Open the expense details and add multiple comments (20 or more)
  4. Scroll up and submit the expense
    4, Retract the expense
  5. Change the category or tag
  6. Navigate away from the expense, then return to it

Expected Result:

Updating the category or tag should not cause the bottom comments to briefly appear

Actual Result:

In Steps 6 and 7, the bottom comments briefly appear whenever opening the expense detail page or updating the category or tag

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
Bug7004444_1763161618387.bandicam_2025-11-15_01-31-18-981.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021990264804839923457
  • Upwork Job ID: 1990264804839923457
  • Last Price Increase: 2025-11-24
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    Daily
    Bug
    on Nov 16, 2025
  2. melvin-bot commented on Nov 16, 2025

    @melvin-bot

    Triggered auto assignment to @VictoriaExpensify (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. added
    External
    on Nov 17, 2025
  4. changed the title [-]Expenses – Bottom comments are briefly displayed when switching between chats[/-] [+][$250] Expenses – Bottom comments are briefly displayed when switching between chats[/+] on Nov 17, 2025
  5. melvin-bot commented on Nov 17, 2025

    @melvin-bot
  6. added
    Help Wanted
    on Nov 17, 2025
  7. melvin-bot commented on Nov 17, 2025

    @melvin-bot

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

  8. proBhavesh commented on Nov 17, 2025

    @proBhavesh

    Proposal

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

    When updating an expense's category or tag and navigating back, the bottom ~50 comments briefly flash on screen during navigation.

    What is the root cause of that problem?

    In transaction/IOU reports, shouldScrollToEndAfterLayout state is initialized to true on mount. When navigating back from category selection, the component remounts with this state still true, causing the FlatList to render with opacity: 0, then transition to opacity: 1 before the scroll corrects. During this transition, the bottom 50 items (from initialNumToRender) are visible, causing the flash.

    State initialization:

    const [shouldScrollToEndAfterLayout, setShouldScrollToEndAfterLayout] = useState(shouldFocusToTopOnMount && !reportActionID);

    Opacity control that causes the flash:

    contentContainerStyle={[
    styles.chatContentScrollView,
    shouldScrollToEndAfterLayout ? styles.opacity0 : styles.opacity1,
    shouldFocusToTopOnMount ? styles.justifyContentEnd : undefined,
    ]}

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

    Add a useLayoutEffect after the visibility effect to detect when remounting a report with existing actions and reset the flag before browser paint:

    useLayoutEffect(() => {
        if (!shouldScrollToEndAfterLayout) return;
        if (reportActionID) return;
        if (sortedVisibleReportActions.length === 0) return;
        if (hasCreatedActionAdded) return;
    
        setShouldScrollToEndAfterLayout(false);
    }, [report.reportID, shouldScrollToEndAfterLayout]);

    Using useLayoutEffect (not useEffect) ensures this runs synchronously before browser paint, preventing any visual flash.

    What alternative solutions did you explore? (Optional)

    N/A

  9. melvin-bot commented on Nov 17, 2025

    @melvin-bot

    📣 @proBhavesh! 📣
    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>
    
  10. proBhavesh commented on Nov 17, 2025

    @proBhavesh

    Contributor details
    Your Expensify account email: probhavsh@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0105269ba7e75f1a0e?mp_source=share

  11. allroundexperts commented on Nov 19, 2025

    @allroundexperts
    Contributor

    @proBhavesh Can you please share the result of applying your proposal? This seems to happen even after applying your fix.

  12. marufsharifi commented on Nov 23, 2025

    @marufsharifi
    Contributor

    Proposal

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

    Expenses – Bottom comments are briefly displayed when switching between chats

    What is the root cause of that problem?

    This PR introduced this issue.

    We returned undefined for the entire maintainVisibleContentPosition object, which made minIndexForVisible effectively undefined. On Web (especially Chrome), undefined does not disable MVCP; instead, the browser treats it as an invalid anchor. This causes Chrome to choose the wrong DOM node as the anchor during the content update, which results in the list jumping or shifting when new items render.

    const maintainVisibleContentPosition = useMemo(() => {
    if (!initialScrollKey && (!isInitialData || !isQueueRendering)) {
    return undefined;
    }

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

    const maintainVisibleContentPosition = useMemo(() => {
    if (!initialScrollKey && (!isInitialData || !isQueueRendering)) {
    return undefined;
    }

    We should return null for minIndexForVisible instead of a undefined or numeric value. Setting it to null fully disables MVCP anchoring during the initial render, which prevents Chrome from incorrectly selecting an anchor item and causing the list to jump. Once the list is stable, MVCP can be re-enabled as needed.

     const maintainVisibleContentPosition = useMemo(() => {
            if (!initialScrollKey && (!isInitialData || !isQueueRendering)) {
                return {
                    minIndexForVisible: null,
                };
            }

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

    None

    What alternative solutions did you explore? (Optional)

  13. 58 remaining items

  14. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  15. mallenexpensify commented on Apr 10, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @marufsharifi paid $250 via Upwork
    Contributor+: @eh2077 due $250 via NewDot

    @marufsharifi can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022042698337234182992

    @eh2077 plz complete the BZ checklist and tag me in a post once you have. Thx

  16. marufsharifi commented on Apr 11, 2026

    @marufsharifi
    Contributor

    @mallenexpensify, I've accepted the offer. thanks.

  17. eh2077 commented on Apr 13, 2026

    @eh2077
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to the comment on the PR: NA
      Link to the comment on the Issue: NA

    The original bug report isn't reproducible anymore and we ended up polishing a new feature, see regression test.

    • [Contributor] 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: NA

    • [Contributor] 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/623712

    Regression Test Proposal

    Precondition:

    • NA

    Test:

    1. Create an expense in Workspace chat
    2. Open the expense details and add multiple comments (20 or more)
    3. Scroll up and submit the expense
    4. Retract the expense
    5. Change the category or tag
    6. Navigate away from the expense
    7. Open the expense again from LHN, and verify you are at the very top.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-6e91-a853-20ea-0e8c1ab9c334
  18. mallenexpensify commented on Apr 13, 2026

    @mallenexpensify
    Contributor

    @marufsharifi paid, summary updated above. Thx.

    ^ Test case created

    thx

  19. laurenreidexpensify commented on Apr 27, 2026

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions