Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 of 8 tasks
jponikarchuk opened this issue Mar 13, 2025 · 57 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@jponikarchuk
Copy link

jponikarchuk commented Mar 13, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] 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): [email protected]
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
@jponikarchuk jponikarchuk added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Mar 13, 2025
Copy link

melvin-bot bot commented Mar 13, 2025

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.

@ryntgh
Copy link
Contributor

ryntgh commented Mar 13, 2025

🚨 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

@Themoonalsofall
Copy link
Contributor

Themoonalsofall commented Mar 13, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-03-13 09:53:25 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?

We are using categoryName from the route to show in header

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

But when we edit category, we back to route with old category name with setNavigationActionToMicrotaskQueue

Navigation.setNavigationActionToMicrotaskQueue(() => {
Navigation.goBack(
isQuickSettingsFlow
? ROUTES.SETTINGS_CATEGORY_SETTINGS.getRoute(policyID, currentCategoryName, backTo)
: ROUTES.WORKSPACE_CATEGORY_SETTINGS.getRoute(policyID, currentCategoryName),
{compareParams: false},
);
});

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

We should use values.categoryName to update both route and header title correctly

            Navigation.setNavigationActionToMicrotaskQueue(() => {
                Navigation.goBack(
                    isQuickSettingsFlow
                        ? ROUTES.SETTINGS_CATEGORY_SETTINGS.getRoute(policyID, values.categoryName, backTo)
                        : ROUTES.WORKSPACE_CATEGORY_SETTINGS.getRoute(policyID, values.categoryName),
                    {compareParams: false},
                );
            });

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

Minor UI bug, no need to test. If needed we can render category edit page with mock data and verify that route and header title is changed after we update category name

What alternative solutions did you explore? (Optional)

We can remove Navigation.setNavigationActionToMicrotaskQueue function

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.

@laurenreidexpensify laurenreidexpensify added the External Added to denote the issue can be worked on by a contributor label Mar 13, 2025
@melvin-bot melvin-bot bot 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 Mar 13, 2025
Copy link

melvin-bot bot commented Mar 13, 2025

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 13, 2025
Copy link

melvin-bot bot commented Mar 13, 2025

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

@daledah
Copy link
Contributor

daledah commented Mar 13, 2025

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.

Copy link

melvin-bot bot commented Mar 17, 2025

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

@melvin-bot melvin-bot bot added the Overdue label Mar 17, 2025
@laurenreidexpensify
Copy link
Contributor

@getusha bump for review of these proposals thanks

@melvin-bot melvin-bot bot removed the Overdue label Mar 17, 2025
@dylanexpensify dylanexpensify moved this to Bugs and Follow Up Issues in #expensify-bugs Mar 18, 2025
Copy link

melvin-bot bot commented Mar 20, 2025

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Mar 20, 2025
Copy link

melvin-bot bot commented Mar 21, 2025

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

@getusha
Copy link
Contributor

getusha commented Mar 21, 2025

Reviewing

@melvin-bot melvin-bot bot removed the Overdue label Mar 21, 2025
@getusha
Copy link
Contributor

getusha commented Mar 21, 2025

@daledah's proposal looks good to me. thanks for the detailed RCA.
🎀 👀 🎀 C+ Reviewed.

Copy link

melvin-bot bot commented Mar 21, 2025

Triggered auto assignment to @puneetlath, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@Themoonalsofall
Copy link
Contributor

@getusha what do you think about my proposal? it actually fixes both title and header errors with a simpler solution. And all the root causes in the selected proposal only happen because we are wrapping the goBack function in the setNavigationActionToMicrotaskQueue function.

cc @puneetlath

@getusha
Copy link
Contributor

getusha commented Mar 21, 2025

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.

@daledah, could you expand on this? I may have overestimated the validity of this case.

@daledah
Copy link
Contributor

daledah commented Mar 21, 2025

@getusha

First of all, as commented here:

// Ensure Onyx.update is executed before navigation to prevent UI blinking issues, affecting the category name and rate.

setNavigationActionToMicrotaskQueue was added in #54239 to fix the UI blink problem where user navigate back too fast so the data is not updated yet. So removing it would cause regression of reintroduce the old bug.

Second, as I stated, if the BE don't accept the category update - which I haven't thought of any case right now, but we can't be so sure in the future, then the failure data here will be merged:

failureData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`,
value: {
[policyCategory.newName]: null,
[policyCategory.oldName]: {
...policyCategoryToUpdate,
errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.categories.updateFailureMessage'),
},
},
},

And the policyCategory here will be undefined:

const policyCategory = policyCategories?.[categoryName] ?? Object.values(policyCategories ?? {}).find((category) => category.previousCategoryName === categoryName);

Because we navigate back using the new category name, which doesn't exist anymore. So user will be hit with a not found page. I believe we're implementing the logics here the way it is to prevent such cases to happen.

And finally, even we somehow have a confirmation that the point above will never happen - which is very optimistic IMO, using goBack with the new value is just a workaround for the real root cause here: We already handled the goBack, it's just not working as expected. So the correct solution here would be to fix the logic to work as expected.

@getusha
Copy link
Contributor

getusha commented Apr 14, 2025

Will finalize today

@melvin-bot melvin-bot bot removed the Overdue label Apr 14, 2025
@getusha
Copy link
Contributor

getusha commented Apr 16, 2025

@daledah can we pin point which PR caused this exactly?

@daledah
Copy link
Contributor

daledah commented Apr 16, 2025

I think it comes from #41722 as they implemented the trigger set params effect, and this logics is unchanged since then.

Copy link

melvin-bot bot commented Apr 22, 2025

@getusha Eep! 4 days overdue now. Issues have feelings too...

@melvin-bot melvin-bot bot added the Overdue label Apr 22, 2025
@getusha
Copy link
Contributor

getusha commented Apr 22, 2025

@daledah's proposal looks good to me.
🎀 👀 🎀 C+ Reviewed.

@melvin-bot melvin-bot bot removed the Overdue label Apr 22, 2025
Copy link

melvin-bot bot commented Apr 22, 2025

Current assignee @puneetlath is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@getusha
Copy link
Contributor

getusha commented Apr 22, 2025

Thanks for the detailed explanation @daledah

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 23, 2025
Copy link

melvin-bot bot commented Apr 23, 2025

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

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Apr 24, 2025
@daledah
Copy link
Contributor

daledah commented Apr 24, 2025

@getusha PR is ready.

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels May 19, 2025
Copy link

melvin-bot bot commented May 19, 2025

This issue has not been updated in over 15 days. @puneetlath, @laurenreidexpensify, @getusha, @daledah eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@puneetlath
Copy link
Contributor

Looks like the PR is on staging.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Monthly KSv2 labels May 20, 2025
@melvin-bot melvin-bot bot changed the title [$250] Categories - RHP header title does not change after updating category name offline [Due for payment 2025-05-27] [$250] Categories - RHP header title does not change after updating category name offline May 20, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 20, 2025
Copy link

melvin-bot bot commented May 20, 2025

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented May 20, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.46-12 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2025-05-27. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented May 20, 2025

@getusha @laurenreidexpensify @getusha The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
Status: Bugs and Follow Up Issues
Development

No branches or pull requests

8 participants