Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.29k stars 2.72k forks source link

[HOLD for Payment 2024-07-22] [$250] Improve ReportScreen rendering time #44925

Closed mountiny closed 1 month ago

mountiny commented 2 months ago

Problem

The Profiler indicates that the ReportScreen render time gets re-rendered dozens of times, with each re-rendering taking an average of 599.8ms.

The most current problems are with this hook:

const lastAccessedReportID = useLastAccessedReportID(!!route.params.openOnAdminRoom);

In this PR we’ve introduced the above hook and there might be several problems with it:

  1. We are calculating lastAccessedReportID in each re-render, however, we only require it in one particular scenario: when the route.params.reportID is empty,
  2. The useLastAccessedReportID hook is heavy, due to the poor performance of the ReportUtils.findLastAccessedReport function. This issue existed before the introduction of the PR mentioned.

Solution

Ad 1. We should calculate the lastAccessedReportID only when needed, that means only once, and only when route.params.reportID is empty (code). This value is used to determine which chat we should show to the user when the user accesses the website without reportID in the URL. POC

Ad 2. After diving deep into the code I’ve discovered that we sort a whole array of reports just to get one, the most recent, report. We can replace this sort with lodashMaxBy, as we do not (from my analysis) need to sort all reports (needs confirmation). POC

cc @kosmydel

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0109e0b5642eb1863c
  • Upwork Job ID: 1809262837407973619
  • Last Price Increase: 2024-07-05
  • Automatic offers:
    • ikevin127 | Reviewer | 103028165
Issue OwnerCurrent Issue Owner: @zanyrenney
melvin-bot[bot] commented 2 months ago

Current assignee @mountiny is eligible for the AutoAssignerNewDotQuality assigner, not assigning anyone new.

melvin-bot[bot] commented 2 months ago

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

melvin-bot[bot] commented 2 months ago

Job added to Upwork: https://www.upwork.com/jobs/~0109e0b5642eb1863c

melvin-bot[bot] commented 2 months ago

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

kosmydel commented 2 months ago

Hey, I’m from Software Mansion and I will take care of this issue :)

melvin-bot[bot] commented 1 month ago

📣 @ikevin127 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job

mountiny commented 1 month ago

A discussed in Slack, please try to split this up to two PRs

melvin-bot[bot] commented 1 month ago

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

ikevin127 commented 1 month ago

⚠️ Automation failed here -> this should be on [HOLD for Payment 2024-07-22] according to today's production deploy from https://github.com/Expensify/App/pull/44948#issuecomment-2229340753 and https://github.com/Expensify/App/pull/44955#issuecomment-2229341167.

I'm the only one requiring payment here for reviewing PRs https://github.com/Expensify/App/pull/44948 and https://github.com/Expensify/App/pull/44955. Additionally, 1 regression was reported above, therefore bounty payment shoud be adjusted to match that - waiting for regression confirmation from @mountiny.

cc @zanyrenney

mountiny commented 1 month ago

$375 to @ikevin127 for reviewing 2 PRs and deducing 50% of one bounty for the regression

ikevin127 commented 1 month ago

@zanyrenney Friendly bump for payments, as I noticed this doensn't have the Daily label which could cause delays.

zanyrenney commented 1 month ago

payment summary

@ikevin127 - paid $375 via upwork @kosmydel - internal contractor - not paid incrementally.

Thanks!