Skip to content

[Due for payment 2026-05-07] [$250] Up/Down arrow keys on the Reports > Reports page do not focus the top/bottom items correctly. #87379

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

Action Performed:

Prerequisite: The user has several reports.

  1. Open the application in a web browser
  2. Navigate to Reports > Reports
  3. Use the up/down arrow keys to navigate focus

Expected Result:

When at the top or bottom of the list, pressing the up or down arrow key should immediately focus the item at the opposite end of the list.

Actual Result:

The up/down arrow keys must be pressed multiple times before the focus returns to the top or bottom of 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

Screenshots/Videos

Recording.2662.mp4
untitled.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022041863440172893172
  • Upwork Job ID: 2041863440172893172
  • Last Price Increase: 2026-04-15
  • Automatic offers:
    • MobileMage | Contributor | 111178124

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 8, 2026
  2. MelvinBot commented on Apr 8, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    In BaseSearchList, the useArrowKeyFocusManager hook is initialized with maxIndex: flattenedItemsLength - 1 (BaseSearchList/index.tsx:51). flattenedItemsLength is the total count of individual transactions across all report groups, computed in SearchList/index.tsx:225-233. However, the FlashList only renders data.length items (the report group rows, not individual transactions).

    This creates a mismatch: the arrow key focus manager cycles through indices 0 to flattenedItemsLength - 1, but only indices 0 to data.length - 1 correspond to rendered items. When focus wraps (e.g., pressing ArrowDown past the last visible item), it traverses all the "ghost" indices one key press at a time — none of which match any rendered item — before reaching a visible item at the opposite end.

    For example, 5 report groups containing 20 total transactions means maxIndex = 19 but only indices 0–4 are visible. Pressing ArrowDown at index 4 requires 16 presses (4→5→6→…→19→0) to wrap back to the top.

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

    Change maxIndex in BaseSearchList/index.tsx:51 from flattenedItemsLength - 1 to data.length - 1 for the arrow key focus manager, so that keyboard navigation only cycles through actually rendered list items.

    flattenedItemsLength should continue to be used where it's needed for select-all/checkbox counting logic, but it should not govern keyboard navigation bounds.

    What alternative solutions did you explore? (Optional)

    An alternative would be to pass disabledIndexes to useArrowKeyFocusManager for all indices >= data.length, but this is unnecessarily complex when simply correcting maxIndex achieves the same result more cleanly.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 8, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 8, 2026
  5. melvin-bot commented on Apr 8, 2026

    @melvin-bot

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

  6. melvin-bot commented on Apr 8, 2026

    @melvin-bot
  7. changed the title [-]Up/Down arrow keys on the Reports > Reports page do not focus the top/bottom items correctly.[/-] [+][$250] Up/Down arrow keys on the Reports > Reports page do not focus the top/bottom items correctly.[/+] on Apr 8, 2026
  8. abbasifaizan70 commented on Apr 8, 2026

    @abbasifaizan70
    Contributor

    Proposal

    What is the root cause of that problem?

    The keyboard focus manager in the search reports list uses a maxIndex derived from flattenedItemsLength, but the list that actually receives focus is rendered from data. In grouped report views, flattenedItemsLength can be much larger than data.length (for example, group rows vs. all child transactions), so arrow navigation steps through non-rendered indexes before it wraps. That is why users need multiple up/down presses before focus appears again at the opposite end.

    const flattenedItems = useMemo(() => {
    if (groupBy || type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) {
    if (!isTransactionGroupListItemArray(data)) {
    return data;
    }
    return data.flatMap((item) => item.transactions);
    }
    return data;
    }, [data, groupBy, type]);

    <BaseSearchList
    data={data}
    renderItem={renderItem}
    onSelectRow={onSelectRow}
    keyExtractor={keyExtractor}
    onScroll={onScroll}
    showsVerticalScrollIndicator={false}
    ref={listRef}
    columns={columns}
    scrollToIndex={scrollToIndex}
    flattenedItemsLength={flattenedItems.length}
    onEndReached={onEndReached}

    const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({
    initialFocusedIndex: -1,
    maxIndex: flattenedItemsLength - 1,
    isActive: isFocused,
    onFocusedIndexChange: (index: number) => {

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

    <BaseSearchList
    data={data}
    renderItem={renderItem}
    onSelectRow={onSelectRow}
    keyExtractor={keyExtractor}
    onScroll={onScroll}
    showsVerticalScrollIndicator={false}
    ref={listRef}
    columns={columns}
    scrollToIndex={scrollToIndex}
    flattenedItemsLength={flattenedItems.length}
    onEndReached={onEndReached}

    <BaseSearchList
        flattenedItemsLength={data.length}
    />

    focusableItemsLength: number;

    const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({
    initialFocusedIndex: -1,
    maxIndex: flattenedItemsLength - 1,
    isActive: isFocused,
    onFocusedIndexChange: (index: number) => {

    const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({
        initialFocusedIndex: -1,
        maxIndex: focusableItemsLength - 1,
        isActive: isFocused,
        onFocusedIndexChange: (index: number) => {
  9. github-actions commented on Apr 8, 2026

    @github-actions
    Contributor

    ⚠️ @abbasifaizan70 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  10. abbasifaizan70 commented on Apr 8, 2026

    @abbasifaizan70
    Contributor

    @ZhenjaHorbach, I added the proposal after the External and Help wanted labels. Please take this while reviewing proposals. Thanks

  11. hamza-nafasat commented on Apr 8, 2026

    @hamza-nafasat

    Proposal

    Problem

    Arrow key navigation requires multiple presses to wrap focus from the last item to the first (and vice versa) in Reports > Reports.

    Root Cause

    The focus manager (useArrowKeyFocusManager) is using flattenedItemsLength as maxIndex, while the UI only renders data.length items.

    This creates a mismatch:

    • Focus logic iterates over all flattened transaction indices
    • UI only has grouped report rows

    Result:
    Focus traverses non-rendered “virtual” indices before reaching a valid item.

    Solution

    Decouple focusable item count from flattened data count.

    Implementation

    1. Introduce a dedicated prop for focus logic:
    focusableItemsLength = data.length
    1. Pass it explicitly to BaseSearchList:
    <BaseSearchList
      ...
      focusableItemsLength={data.length}
    />
    1. Update focus manager usage:
    maxIndex: focusableItemsLength - 1
    1. Keep flattenedItemsLength unchanged for selection/count logic.

    Why this approach

    • Fixes bug (correct wrap behavior)
    • Avoids breaking existing logic using flattened items
    • Makes intent explicit (rendered vs logical data)
    • Prevents similar bugs in future

    Validation

    • Press ↓ on last item → jumps to first ✅
    • Press ↑ on first item → jumps to last ✅
    • Works with grouped reports ✅
    • No regression in selection/count logic ✅
  12. melvin-bot commented on Apr 8, 2026

    @melvin-bot

    📣 @hamza-nafasat! 📣
    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>
    
  13. 65 remaining items

  14. changed the title [-][$250] Up/Down arrow keys on the Reports > Reports page do not focus the top/bottom items correctly.[/-] [+][Due for payment 2026-05-07] [$250] Up/Down arrow keys on the Reports > Reports page do not focus the top/bottom items correctly.[/+] on Apr 30, 2026
  15. melvin-bot commented on Apr 30, 2026

    @melvin-bot

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

  16. melvin-bot commented on Apr 30, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.64-31 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 2026-05-07. 🎊

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

  17. melvin-bot commented on Apr 30, 2026

    @melvin-bot

    @ZhenjaHorbach 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]

  18. melvin-bot commented on May 4, 2026

    @melvin-bot

    @ZhenjaHorbach Whoops! This issue is 2 days overdue. Let's get this updated quick!

  19. melvin-bot commented on May 6, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  20. ZhenjaHorbach commented on May 7, 2026

    @ZhenjaHorbach
    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: https://github.com/Expensify/App/pull/68455/changes#r3200463967

    • [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.

    Regression Test Proposal

    Test:

    1. Open the application in a web browser
    2. Navigate to Reports > Reports (ensure the user has several reports)
    3. Use the Down arrow key to move focus through the list
    4. When focus reaches the last item, press Down once more
    5. Verify focus wraps immediately to the first item
    6. Press Up on the first item
    7. Verify focus wraps immediately to the last item

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-598e-ad67-d97c-9aeb0df4ad24
  21. mallenexpensify commented on May 7, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @MobileMage paid $250 via Upwork
    Contributor+: @ZhenjaHorbach due $250 via NewDot

    ^ Test case created

    Thx

  22. garrettmknight commented on May 10, 2026

    @garrettmknight
    Contributor

    $250 approved for @ZhenjaHorbach

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions