Skip to content

[Due for payment 2025-06-09] [$125] Per diem - Degraded performance in Per diem page #61822

Closed

Description

@jponikarchuk

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.1.43-7
Reproducible in staging?: Yes
Reproducible in production?: Unable to check, new feature
If this was caught during regression testing, add the test name, ID and link from TestRail: #60488
Email or phone of affected tester (no customers): applausetester+khcategory19@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.3 / Chrome
App Component: Workspace Settings

Action Performed:

Precondition:

  • Workspace has per diem rates (use the file below).
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Per diem
  3. Click on the checkbox of any item.
  4. Note that the dropdown button appears first then the checkbox is only marked after a few seconds.
  5. On mweb Chrome, tap on the search field and search for a country.
  6. Note that typing on the search field is laggy and the search results delay.

Expected Result:

In Step 4, the checkbox will appear marked at the same time as when the dropdown button appears.
In Step 6, on mweb, typing on the search field will not be laggy and the search results will return instantly.

Actual Result:

In Step 4, the dropdown button appears first then the checkbox is only marked after a few seconds.
In Step 6, on mweb, typing on the search field is laggy and the search results delay.

When Step 3 to 6 are performed a few times, both web and mweb devices heat up a lot.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6827135_1746860743185.web.mp4
Bug6827135_1746860743237.mweb_chrome.mp4

Bug6827135_1746860809922!logs-2025-05-10_07_06_29.572.txt

Bug6827135_1746860743195!German_Per_Diem_-Dependent_Tags___2.csv

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021922118344435967366
  • Upwork Job ID: 1922118344435967366
  • Last Price Increase: 2025-06-10
Issue OwnerCurrent Issue Owner: @zanyrenney

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 10, 2025
  2. melvin-bot commented on May 10, 2025

    @melvin-bot

    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.

  3. melvin-bot commented on May 10, 2025

    @melvin-bot

    Triggered auto assignment to @pecanoro (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  4. melvin-bot commented on May 10, 2025

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on May 10, 2025

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. Eskalifer1 commented on May 10, 2025

    @Eskalifer1
    Contributor

    Hi, I found a bug that is partially related to this task as it also causes performance issues. Is it possible to create a separate task for that with my suggestion for that? I would have raised this issue in Slack, but I still haven't been granted access there, so I can't ask it there yet

    2025-05-10.15.30.59.mov

    Proposal

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

    Per diem - Degraded performance in Per diem page

    What is the root cause of that problem?

    The problem of constant rendering of the component arises due to a change in the memory reference to the allRatesArray and allSubRates objects

    const allRatesArray = Object.values(customUnitRates);
    const allSubRates = getSubRatesData(allRatesArray);

    As a result, although the objects remain unchanged, they have a different memory reference and are therefore considered new objects, which, as a result, causes the subRatesList to change through useMemo:
    [allSubRates, selectedPerDiem, canSelectMultiple, styles.flex2, styles.alignItemsStart, styles.textSupporting, styles.label, styles.pl2, styles.alignSelfEnd],

    Which, in turn, re-render the entire component:

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

    We need to add useMemo for these 2 objects

     const allRatesArray = useMemo(() => Object.values(customUnitRates), [customUnitRates]);
    
        const allSubRates = useMemo(() => getSubRatesData(allRatesArray), [allRatesArray]);

    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)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  7. Eskalifer1 commented on May 10, 2025

    @Eskalifer1
    Contributor

    Proposal

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

    Per diem - Degraded performance in Per diem page

    What is the root cause of that problem?

    If you take a closer look, the problem is not only for this page, but for all pages that use the useSearchResults hook, it's just that on other pages the operations are performed faster, which is why the difference is very small and hard to notice.

    The problem is as follows:

    function useSearchResults<TValue>(data: TValue[], filterData: (datum: TValue, searchInput: string) => boolean, sortData: (data: TValue[]) => TValue[] = (d) => d) {

    This hook uses useTransition to de-prioritize certain tasks, so an extra render is performed, and the change itself is performed in useEffect, resulting in only one change but 3 renders.

    In turn, the button uses the local state of the component, not the state from the filteredValue,

    const [selectedPerDiem, setSelectedPerDiem] = useState<SubRateData[]>([]);

    Because of this, we have selectedPerDiem changing on the first render, useEffect is used for 2 renders, and useTransition is used for the third render, which changes the state of the table

    customText={translate('workspace.common.selected', {count: selectedPerDiem.length})}

    const [inputValue, setInputValue, filteredSubRatesList] = useSearchResults(subRatesList, filterRate, sortRates);
    const sections = useMemo(() => [{data: filteredSubRatesList, isDisabled: false}], [filteredSubRatesList]);

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

    The problem clearly arises because of useTransition, because it is through it that changes occur in useEffect that causes every single render, if you remove the logic from useTransition, then the hook will look like this:

    function useSearchResults<TValue>(data: TValue[], filterData: (datum: TValue, searchInput: string) => boolean, sortData: (data: TValue[]) => TValue[] = (d) => d) {
     const [inputValue, setInputValue] = useState('');
     const prevData = usePrevious(data);
    
        const normalizedSearchQuery = inputValue.trim().toLowerCase();
     const filtered = normalizedSearchQuery.length ? data.filter((item) => filterData(item, normalizedSearchQuery)) : data;
     const sorted = sortData(filtered);
    
        useEffect(() => {
     if (prevData.length <= CONST.SEARCH_ITEM_LIMIT || data.length > CONST.SEARCH_ITEM_LIMIT) {
     return;
     }
     setInputValue('');
     }, [data, prevData]);
    
        return [inputValue, setInputValue, sorted] as const;
    }

    With this approach, only one render will occur and the changes will be synchronized and occur simultaneously, but then the logic from useTransition is lost (I don't know what it is for, but I'm sure it is needed, because it would not be added for nothing).

    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)

    Another way to avoid changing the useSearchResults hook is to set the “Selected” button to a value from the filteredSubRatesList instead of the local state, so that both the button and the table use the same value, but in this case, it may have a bad impact on the UX, since the changes will not occur immediately, but with a delay
    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  8. 56 remaining items

  9. ikevin127 commented on Jun 6, 2025

    @ikevin127
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: Initial PR: [CP Staging] fix: search bar performance followup #61844, no need for comment since this is a follow-up to that initial PR.

    • [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: N/A

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

    Regression Test Proposal

    Precondition: Workspace has per diem rates.

    1. Go to workspace settings > Per diem.
    2. Click on the checkbox of any item.
    3. Verify that selection mode and item selected state displays immediately without performance delays.
    4. Perform various actions to the page.
    5. Verify that actions are performed without performance delays.

    Do we agree 👍 or 👎.

  10. ikevin127 commented on Jun 6, 2025

    @ikevin127
    Contributor

    @zanyrenney As per CME comment, only I require payment here, and payment will be $125 because we had regression after the initial PR. I will request payment through NewDot Manual Requests ✅

  11. ikevin127 commented on Jun 9, 2025

    @ikevin127
    Contributor

    Actually, to follow up on 👆, as just pointed out on Slack by @thesahindia, the PR for this issue caused 2 more than 2 regressions, and given the guidelines mentioning -50% penalty for each regression, this would technically mean no payment due here I guess ? 😅

    With the above context in mind, I'd like to propose and ask for full bounty payment ($250) here, despite the two regressions, and here's the justification:

    • the PR for this issue: fix: selection performance improvements was a complex feat with lots of changes in over 14 files which when delivered, it greatly improved the app's performance and user experience
    • the regressions were minor issues which were quickly demoted from deploy blocker status and promptly addressed in follow-up PRs

    Given these two reasons, I think full payment is justified here, regardless of regressions which are expected with major UI restructuring, and given the significant performance increase delivered to the app.

    Note: Here's a similar example of an issue (ref1, ref2), where we had more than 2 regressions / follow-ups, where the initial issue bounty was actually doubled due to feature complexity and prompt value delivery.

    cc @mountiny for review / decision on payment request

  12. melvin-bot commented on Jun 9, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@zanyrenney)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1922118344435967366/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  13. mountiny commented on Jun 10, 2025

    @mountiny
    Contributor

    This issue in itself has already been a follow up/ regression from the original big PR. While I sympathise with you and agree it has bee non-trivial task, I do think we need to encourage people to test more thoroughly as more regressions just lead to more time spend by the team trying to fix them, or to more payments to be issued for those regressions that should not have occurred in a first place.

    As such I suggest payout of only $125 and not the full price.

  14. changed the title [-][Due for payment 2025-06-09] [$250] Per diem - Degraded performance in Per diem page[/-] [+][Due for payment 2025-06-09] [$125] Per diem - Degraded performance in Per diem page[/+] on Jun 10, 2025
  15. melvin-bot commented on Jun 10, 2025

    @melvin-bot

    Upwork job price has been updated to $125

  16. zanyrenney commented on Jun 10, 2025

    @zanyrenney
    Contributor

    Lowering the payment since 2 regressions were caused.

  17. zanyrenney commented on Jun 10, 2025

    @zanyrenney
    Contributor

    Payment Summary

    Upwork Job

    BugZero Checklist (@zanyrenney)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1922118344435967366/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  18. ikevin127 commented on Jun 10, 2025

    @ikevin127
    Contributor

    There was only 1 reviewer due payment on this issue, see #61822 (comment).

  19. zanyrenney commented on Jun 10, 2025

    @zanyrenney
    Contributor

    Updated as per the comment above, thanks for letting me know @ikevin127

  20. JmillsExpensify commented on Jun 11, 2025

    @JmillsExpensify
    Contributor

    $125 approved for @ikevin127

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.DailyKSv2EngineeringExternalAdded 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