Skip to content

[Due for payment 2025-05-27] [$250] Categories - RHP header title does not change after updating category name offline #58351

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.12-5
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): applausetester+130302kh@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.3 / Chrome
App Component: Workspace Settings

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Categories.
  3. Go offline.
  4. Click any category.
  5. Click Name.
  6. Edit the name and save it.

Expected Result:

The RHP header title will update.

Actual Result:

The RHP header title does not update.
It only updates after closing and reopening the RHP.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6769510_1741856108441.category.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021900183016820569237
  • Upwork Job ID: 1900183016820569237
  • Last Price Increase: 2025-03-20
  • Automatic offers:
    • daledah | Contributor | 107035945
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @laurenreidexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 13, 2025
  2. melvin-bot commented on Mar 13, 2025

    @melvin-bot

    Triggered auto assignment to @laurenreidexpensify (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. ryntgh commented on Mar 13, 2025

    @ryntgh
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-03-13 09:37:48 UTC.

    Proposal

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

    Categories - RHP header title does not change after updating category name offline

    What is the root cause of that problem?

    The header title was dependent on the route parameter categoryName, which wasn't updated immediately when the category name changed offline due to delays in propagating route parameter updates

    <HeaderWithBackButton
    title={categoryName}
    onBackButtonPress={navigateBack}
    />

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

    Instead of using the route parameter, directly use the category name from the policy data (policyCategory.name), which is updated optimistically via Onyx even when offline

    <HeaderWithBackButton
        title={policyCategory.name}
        onBackButtonPress={navigateBack}
    />

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    We could create a test to ensure that the header updates immediately after the category name is changed, if needed

    What alternative solutions did you explore? (Optional)

    New-Expensify.mp4
  4. changed the title [-]Categories - RHP header title does not change after updating category name offline[/-] [+][$250] Categories - RHP header title does not change after updating category name offline[/+] on Mar 13, 2025
  5. melvin-bot commented on Mar 13, 2025

    @melvin-bot
  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 13, 2025
  7. melvin-bot commented on Mar 13, 2025

    @melvin-bot

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

  8. daledah commented on Mar 13, 2025

    @daledah
    Contributor

    Proposal

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

    The RHP header title does not update.
    It only updates after closing and reopening the RHP.

    What is the root cause of that problem?

    We already have a logic to change the params and title when category are edited here:

    useEffect(() => {
    if (policyCategory?.name === categoryName || !policyCategory) {
    return;
    }
    navigation.setParams({categoryName: policyCategory?.name});
    }, [categoryName, navigation, policyCategory]);

    So navigating back using old category name is not the real RCA that caused the issue.

    When opening the Category edit page, the Category settings page is not removed from the screen, it's just hidden behind the edit page. This behavior makes the above useEffect logic still active.

    When we edit the category name, changes in dependency triggers the effect, changing the params. However, user are still in the Category edit page, so the navigation.setParams only change the param for the Edit page, and not the Category page. All of this happens before user even navigate back.

    But why we still see the URL is updated when navigating back when online?

    Because we use policyCategory as dependency. When updating category name, we set pendingFields value:

    pendingFields: {
    ...(policyCategoryToUpdate?.pendingFields ?? {}),
    name: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
    },

    And when API call sucessfully, we remove them:

    pendingFields: {
    name: null,
    },

    The latter update triggers the effect again, making navigation.setParams run once more after navigate back to Category page. So we get the little delay and then have the correct URL and title.

    When offline, successData is not merged, so navigating back to Category page doesn't trigger another setParams.

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

    Only change the title doesn't solve the whole problem because the URL is not changed.

    Navigating back using the updated category name is risky and not future proof, because BE might not accept the change and reset the old value. In this case user will get a Not found page.

    Instead, we should trigger the setParams effect on page focus

    useEffect(() => {
    if (policyCategory?.name === categoryName || !policyCategory) {
    return;
    }
    navigation.setParams({categoryName: policyCategory?.name});
    }, [categoryName, navigation, policyCategory]);

        const isFocused = useIsFocused();
    
        useEffect(() => {
            if (policyCategory?.name === categoryName || !policyCategory || !isFocused) {
                return;
            }
            navigation.setParams({categoryName: policyCategory?.name});
        }, [categoryName, navigation, policyCategory, isFocused]);

    Optionally, set dependency only on policyCategory?.name to prevent unwanted effect trigger

    useEffect(() => {
            if (policyCategory?.name === categoryName || !isFocused) {
                return;
            }
            navigation.setParams({categoryName: policyCategory?.name});
        }, [categoryName?.name, navigation, policyCategory, isFocused]);

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    We can create a test to simulate the edit category name flow and make sure that the title and url is correctly set.

    What alternative solutions did you explore? (Optional)

    NA

    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.

  9. melvin-bot commented on Mar 17, 2025

    @melvin-bot

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

  10. 84 remaining items

  11. laurenreidexpensify commented on May 29, 2025

    @laurenreidexpensify
    Contributor

    @getusha bump thanks

  12. getusha commented on May 29, 2025

    @getusha
    Contributor

    Will complete the checklist until EOD tomorrow.

  13. removed their assignment
    on May 30, 2025
  14. added
    BugSomething is broken. Auto assigns a BugZero manager.
    and removed
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 30, 2025
  15. melvin-bot commented on May 30, 2025

    @melvin-bot

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

  16. laurenreidexpensify commented on May 30, 2025

    @laurenreidexpensify
    Contributor

    👋 @adelekennedy I am OOO til 9 June, can you please issue payments once checklist is complete + add anything to testrail. Thank you!

  17. getusha commented on Jun 2, 2025

    @getusha
    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: Seems like we didn't consider offline behavior on implementation of the page.

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

    • None

    Test:

    1. Open app
    2. Go to workspace settings > Categories
    3. Go offline
    4. Click any category
    5. Click Name
    6. Edit the name and save it

    Do we agree 👍 or 👎

  18. adelekennedy commented on Jun 2, 2025

    @adelekennedy
    Contributor

    Payment Summary

    Contributor: @daledah paid $250 via Upwork
    Contributor+: @getusha due $250 via NewDot

  19. moved this from Bugs and Follow Up Issues to Done in #expensify-bugson Jun 2, 2025
  20. garrettmknight commented on Jun 26, 2025

    @garrettmknight
    Contributor

    $250 approved for @getusha

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