Skip to content

Pre-compute report action visibility #79500

@mountiny

Description

@mountiny

Coming from here

Background

When users open a chat or expense report, they see a list of messages, requests, and system notifications. Not all actions stored in the database should be displayed - some are deleted, some are private whispers meant for other users, some are deprecated action types, and some are pending removal. Before showing the list, the app must determine which actions are visible to the current user.

This visibility check (shouldReportActionBeVisible) is called across ~13 different call sites throughout the app. For reports with many actions (100+), each call site runs through every action individually, evaluating multiple conditions. This causes redundant computation on app startup and core flows.

The app already has a pattern for avoiding this kind of repeated work: pre-computing values when data changes rather than when screens render. This pattern is used successfully in other parts of the app for report attributes and transaction data.

Problem

The same visibility calculation runs multiple times across different call sites, causing sluggish app startup and slow core flows like creating expenses.

Solution

Create a new Onyx Derived Value VISIBLE_REPORT_ACTIONS that pre-computes visibility when data changes:

  • Use shouldReportActionBeVisible in the derived value computation to pre-calculate visibility
  • Replace direct calls with derived value lookups across ~13 call sites
  • Use sourceValues for incremental updates - full recomputation only happens on OpenApp/ReconnectApp
    Static checks (action type, whisper targeting, deleted state) move to the derived value. Runtime checks (offline state, write permissions) remain in the component.

The optimization applies to ReportActionsView, MoneyRequestReportActionsList, LHN, and other call sites.

Performance

Tested on a heavy account:

  • App startup: ~200ms saved
  • Create expense: ~1.2s saved
  • Initial compute adds ~31ms for ~2500 actions

With sourceValues, we only recompute what changed. The current Onyx callback computes everything on every update, so this is strictly better.

Issue OwnerCurrent Issue Owner: @BartekObudzinski

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.MonthlyKSv2ReviewingHas a PR in review

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions