Skip to content

[$250] [Due for payment 2026-03-24] Migrate ModifiedExpenseMessage.ts from Onyx.connect to useOnyx pattern #80263

Closed

Description

@marcochavezf

Coming from Coming from here

Overview

The ModifiedExpenseMessage.ts file uses Onyx.connectWithoutView to maintain module-level state for allPolicyTags and currentUserLogin.

Current Architecture

The file uses module-level Onyx connections:

let allPolicyTags: OnyxCollection<PolicyTagLists> = {};
Onyx.connectWithoutView({
    key: ONYXKEYS.COLLECTION.POLICY_TAGS,
    // ...
});

let currentUserLogin = '';
Onyx.connectWithoutView({
    key: ONYXKEYS.SESSION,
    // ...
});

These are used by getForReportAction() which is called from:

  • ReportActionItem.tsx
  • ContextMenuActions.tsx
  • BrowserNotifications.ts
  • OptionsListUtils/index.ts
  • ReportNameUtils.ts
  • ReportUtils.ts

Migration Plan

The goal is to make getForReportAction a pure function that receives policyTags and currentUserLogin as parameters from the call site.

PR 1: ReportActionItem.tsx + ContextMenuActions.tsx ✅

Status: In Progress (#80258)

  • Add useOnyx hooks to fetch policyTags and session in React components
  • Use getForReportActionTemp which accepts all required parameters
  • Pass translate, policy, policyTags, and currentUserLogin from components

PR 2: BrowserNotifications.ts

Scope: 1 file, straightforward

Browser notifications are non-UI code. We can pass empty/undefined values for parameters that aren't needed in notification context, or thread the values from where notifications are triggered.

PR 3: OptionsListUtils getLastMessageTextForReport

Scope: ~4-5 files

This function already accepts some parameters. We need to:

  1. Add policyTags and currentUserLogin parameters
  2. Switch to the pure function version
  3. Update the 5 callers

PR 4: ReportNameUtils computeReportName

Scope: ~8-9 files

Similar approach:

  1. Add parameters to computeChatThreadReportName and computeReportName
  2. Update 12 callers across 8 files

PR 5: Final Cleanup

Scope: 1 file

Once PRs 2-4 are complete:

  1. Remove getForReportAction (old function)
  2. Rename getForReportActionTemp → getForReportAction
  3. Remove the module-level Onyx connections
  4. Remove eslint-disable comments

What about ReportUtils.getReportName?

The deprecated getReportName function in ReportUtils.ts has 42 callers. Since it's already marked as deprecated (developers should use computeReportName instead), we don't need to actively migrate all those callers. Once PR 4 is done, the recommended function will be fully migrated.

Related PRs

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022036562798754115810
  • Upwork Job ID: 2036562798754115810
  • Last Price Increase: 2026-03-24

Activity

  1. self-assigned this
    on Jan 22, 2026
  2. tgolen commented on Jan 22, 2026

    @tgolen
    Contributor

    Thanks Marco! We need to go with Option A. We've been working for 4 months now to remove the anti-patterns of the "module-level state".

  3. luacmartins commented on Jan 22, 2026

    @luacmartins
    Contributor

    I agree with Tim. We need to make any functions using tags and currentUserLogin pure functions and pass that data from the call site.

  4. marcochavezf commented on Jan 22, 2026

    @marcochavezf
    ContributorAuthor

    Ok, thanks for the feedback! I updated the plan to gradually migrate it

  5. linhvovan29546 commented on Jan 23, 2026

    @linhvovan29546
    Contributor

    Hello, coming from a small discussion here ! I think in this issue we only need to migrate the functions to accept a currentUserLogin parameter for getForReportAction and getForReportActionTemp, and we should not replace getForReportAction with getForReportActionTemp.

    The reason is that this issue #66336 #75562 is migrating to remove POLICY_TAGS, so touching too much in this file would introduce hard conflicts

  6. melvin-bot commented on Jan 28, 2026

    @melvin-bot

    @marcochavezf Huh... This is 4 days overdue. Who can take care of this?

  7. melvin-bot commented on Jan 30, 2026

    @melvin-bot

    @marcochavezf 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  8. marcochavezf commented on Feb 3, 2026

    @marcochavezf
    ContributorAuthor

    No update, we prioritized sprint projects last week, now I will prioritize this one again

  9. parasharrajat commented on Feb 5, 2026

    @parasharrajat
    Member

    We are working on a similar issue here #66336, which precedes this one.

  10. 55 remaining items

  11. joekaufmanexpensify commented on Mar 24, 2026

    @joekaufmanexpensify
    Contributor

    We discussed and think $500 each is fair here. Any concerns with that @linhvovan29546 @parasharrajat ?

  12. joekaufmanexpensify commented on Mar 24, 2026

    @joekaufmanexpensify
    Contributor

    Payment Summary

  13. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 24, 2026
  14. melvin-bot commented on Mar 24, 2026

    @melvin-bot

    Current assignees @parasharrajat and @linhvovan29546 are eligible for the External assigner, not assigning anyone new.

  15. changed the title [-][Due for payment 2026-03-24] Migrate ModifiedExpenseMessage.ts from Onyx.connect to useOnyx pattern[/-] [+][$250] [Due for payment 2026-03-24] Migrate ModifiedExpenseMessage.ts from Onyx.connect to useOnyx pattern[/+] on Mar 24, 2026
  16. melvin-bot commented on Mar 24, 2026

    @melvin-bot
  17. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 24, 2026
  18. joekaufmanexpensify commented on Mar 24, 2026

    @joekaufmanexpensify
    Contributor

    @linhvovan29546 offer sent for $500

  19. linhvovan29546 commented on Mar 25, 2026

    @linhvovan29546
    Contributor

    @linhvovan29546 offer sent for $500

    I've accepted the offer

  20. mallenexpensify commented on Mar 25, 2026

    @mallenexpensify
    Contributor

    @linhvovan29546 paid, summary updated above. Thx.

  21. parasharrajat commented on Apr 20, 2026

    @parasharrajat
    Member

    Payment requested as per #80263 (comment)

  22. garrettmknight commented on Apr 23, 2026

    @garrettmknight
    Contributor

    $500 approved for @parasharrajat

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

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions