Skip to content
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

[HOLD for payment 2024-03-04] [$250] Remove MoneyRequestCategoryPage.js and copy any changes since Nov 27 into IOURequestStepCategory.js #34606

Closed
Tracked by #29107
tgolen opened this issue Jan 16, 2024 · 38 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review

Comments

@tgolen
Copy link
Contributor

tgolen commented Jan 16, 2024

This is a part of #29107. You can look at that issue for more context behind the cleanup process.

Problem

The app has two redundant components:

Old Component: MoneyRequestCategoryPage
New Component IOURequestStepCategory

Solution

Following the examples (example 1, example 2), the Old Component needs to be completely removed from the codebase

  1. Look at the history of the Old Component
  2. If there are any changes since Nov 27, 2023 which have not been added to the New Component, copy those changes
  3. Replace all uses of the Old Component with the New Component
  4. Remove all traces of Old Component
  5. Be sure to update all routes and navigation to use the new :action param (instead of being hard-coded with "create")
  6. Update any logic like isEditing to use the new action param from the route
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01aa1b22b861ac0e42
  • Upwork Job ID: 1747632761920925696
  • Last Price Increase: 2024-01-24
  • Automatic offers:
    • DylanDylann | Contributor | 28129737
    • dukenv0307 | Contributor | 28130978
@tgolen tgolen added Engineering Daily KSv2 Help Wanted Apply this label when an issue is open to proposals by contributors Bug Something is broken. Auto assigns a BugZero manager. labels Jan 16, 2024
Copy link

melvin-bot bot commented Jan 16, 2024

Triggered auto assignment to @anmurali (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@neonbhai
Copy link
Contributor

would love to work on this!

@tgolen
Copy link
Contributor Author

tgolen commented Jan 16, 2024

Please add a proposal for the changes that are necessary (I know I gave a brief overview, but your proposal should cover more details as I copy/pasted that into at least a dozen issues).

@neonbhai
Copy link
Contributor

neonbhai commented Jan 16, 2024

Proposal

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

Remove MoneyRequestCategoryPage.js and copy any changes since Nov 27 into IOURequestStepCategory.js

What is the root cause of that problem?

Clean Up
 of MoneyRequestCategoryPage

What changes do you think we should make in order

We will be deleting the component here:

function MoneyRequestCategoryPage({route, report, iou}) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const reportID = lodashGet(route, 'params.reportID', '');

This file will be removed. Checking history (link), it seems like useTheme import was updated, which seems correct in IOURequestStepCategory.js.

We will remove the screen from ModalStackNavigators.tsx

[SCREENS.MONEY_REQUEST.CATEGORY]: () => require('../../../pages/iou/MoneyRequestCategoryPage').default as React.ComponentType,



We will make sure the IOURequestStepCategory component works correctly.

@lindseydortch
Copy link

lindseydortch commented Jan 16, 2024

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

We want to remove the MoneyRequestCategoryPage and make sure any changes after November 27 have been included into these new components.

What is the root cause of that problem?

This is a part of the Wave 5 cleanup effort, so the goal is to refactor the navigation among screens.

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

  1. A new component IOURequestStepCategory has been created and history has been checked against MoneyRequestCategoryPage.
  2. There is only one change since November 27 which moved the location of the useThemeStyles import was changed to Line 10 instead of 13, so no changes need to be copied into the IOURequestStepCategory because it is already ikn there.
    import useThemeStyles from '@hooks/useThemeStyles';

    3 and 4. The only instance where this component is called and needs to be replaced with new component is
    [SCREENS.MONEY_REQUEST.CATEGORY]: () => require('../../../pages/iou/MoneyRequestCategoryPage').default as React.ComponentType,
  3. The route will then need to be updated in (if applicable)
    route: ':action/:iouType/scan/:transactionID/:reportID',
  4. I didn't see any updating logic in this file, so we should be able to skip this step here

What alternative solutions did you explore? (Optional)

N/A

@njmulsqb
Copy link

I would love to take this!

@tgolen tgolen added the External Added to denote the issue can be worked on by a contributor label Jan 17, 2024
@melvin-bot melvin-bot bot changed the title Remove MoneyRequestCategoryPage.js and copy any changes since Nov 27 into IOURequestStepCategory.js [$500] Remove MoneyRequestCategoryPage.js and copy any changes since Nov 27 into IOURequestStepCategory.js Jan 17, 2024
Copy link

melvin-bot bot commented Jan 17, 2024

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

Copy link

melvin-bot bot commented Jan 17, 2024

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

@ghost
Copy link

ghost commented Jan 17, 2024

I want to work on it

@ishpaul777
Copy link
Contributor

I'd like to work in this

@tgolen
Copy link
Contributor Author

tgolen commented Jan 17, 2024

As a reminder: comments like "I would like to work on this" have nothing to do with who is selected to do the work. I appreciate the gusto though! Please follow the contributor guidelines.

@ishpaul777

This comment was marked as outdated.

@dukenv0307
Copy link
Contributor

dukenv0307 commented Jan 17, 2024

Proposal

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

Remove MoneyRequestCategoryPage.js and copy any changes since Nov 27 into IOURequestStepCategory.js

What is the root cause of that problem?

This is a refactor

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

Look at the history of the Old Component
If there are any changes since Nov 27, 2023, which have not been added to the New Component, copy those changes

  1. The history change here: https://github.com/Expensify/App/commits/main/src/pages/iou/MoneyRequestCategoryPage.js

We only have had one change since Nov 27, 2023 and it's migration theme change. So no need to change here

Replace all uses of the Old Component with the New Component
Remove all traces of Old Component

  1. MoneyRequestCategoryPage isn't used in any component so we don't need to have any updates here.

We only need to remove MoneyRequestCategoryPage in ModalStackNavigators, remove .MONEY_REQUEST.CATEGORY from SCREENS, and remove MONEY_REQUEST_CATEGORY route

[SCREENS.MONEY_REQUEST.CATEGORY]: () => require('../../../pages/iou/MoneyRequestCategoryPage').default as React.ComponentType,

Be sure to update all routes and navigation to use the new :action param (instead of being hard-coded with "create")

  1. Update the getRoute function with an extra param action and return it instead of always returning create
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo: string) =>
            getUrlWithBackToParam(`${action}/${iouType}/category/${transactionID}/${reportID}`, backTo),

App/src/ROUTES.ts

Lines 329 to 330 in a8acf44

getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`create/${iouType}/category/${transactionID}/${reportID}`, backTo),

Update any logic like isEditing to use the new action param from the route

  1. Re-use IOURequestStepCategory for the edit case and remove EditRequestCategoryPage. We can get the action from the route param to update the logic when saving the date accordingly.

To handle updateCategory function for edit case we can re-use the logic of saveCategory in EditRequestPage.

And when we click on the date option in MoneyRequestView we will navigate to the route of IOURequestStepCategory with action param is edit.

  1. Re-use IOURequestStepCategory for the edit split bill case. We can check this case by checking action and iouType param. We can re-use setDraftSplitTransaction function in EditSplitBillPage to update updateCategory fucntion.

What alternative solutions did you explore? (Optional)

NA

@mountiny mountiny changed the title [$500] Remove MoneyRequestCategoryPage.js and copy any changes since Nov 27 into IOURequestStepCategory.js [$250] Remove MoneyRequestCategoryPage.js and copy any changes since Nov 27 into IOURequestStepCategory.js Jan 17, 2024
Copy link

melvin-bot bot commented Jan 17, 2024

Upwork job price has been updated to $250

@melvin-bot melvin-bot bot added the Overdue label Jan 19, 2024
@anmurali
Copy link

@thesahindia - can you review the two proposals above please?

@melvin-bot melvin-bot bot removed the Overdue label Jan 22, 2024
@brunovjk
Copy link
Contributor

brunovjk commented Jan 23, 2024

Proposal

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

This belongs to Wave 5 cleanup
Phase 2 is all about removing the original components and any of the duplicated efforts.

What is the root cause of that problem?

Replace MoneyRequestCategoryPage and EditRequestCategoryPage to IOURequestStepCategory. This new component will handle both the create and edit flow based on action param.

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

Look at the history of the Old Component
If there are any changes since Nov 27, 2023 which have not been added to the New Component, copy those changes

  1. From history change. We can see that only one update was made to the 'useThemeStyles path'. This change is also seen in the new component. This way there will be no need to arrange any changes from MoneyRequestCategoryPage to be transferred to IOURequestStepCategory.

Replace all uses of the Old Component with the New Component
Remove all traces of Old Component

  1. There is no use of the component other than ModalStackNavigators. We must remove the MoneyRequestCategoryPage component along with:

    [SCREENS.MONEY_REQUEST.CATEGORY]: () => require('../../../pages/iou/MoneyRequestCategoryPage').default as React.ComponentType,

  2. The new component uses STEP_CATEGORY and has it own linkingConfig, SCREENS and ROUTES already configured, we must remove CATEGORY from linkingConfig, SCREENS and ROUTES

Be sure to update all routes and navigation to use the new :action param (instead of being hard-coded with "create")

  1. Update route and getRoute to use the new :action param.
        MONEY_REQUEST_STEP_CATEGORY: {
            route: ':action/:iouType/category/:transactionID/:reportID?',
            getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo: string) =>
                getUrlWithBackToParam(`${action}/${iouType}/category/${transactionID}/${reportID}`, backTo),
    },
    
  2. Update Type navigation according to new route and getRoute.
        [SCREENS.MONEY_REQUEST.STEP_CATEGORY]: {
            iouType: string;
            transactionID: string;
            reportID: string;
            backTo: string;
        };
    
  3. Add CONST.IOU.ACTION.CREATE at MoneyTemporaryForRefactorRequestConfirmationList to follow ROUTES.MONEY_REQUEST_STEP_CATEGORY changes.
    Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()))
    

Update any logic like isEditing to use the new action param from the route

  1. Update MoneyRequestView to follow ROUTES.MONEY_REQUEST_STEP_CATEGORY changes.

    Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction.transactionID, report.reportID, Navigation.getActiveRouteWithoutParams()))
    
  2. Add an isDraft variable to control if we are CREATing or EDITing. Update IOURequestStepCategory.js to accommodate the CREATE and EDIT of the Category field. We need to use IOU.updateMoneyRequestCategory as was done in EditRequestPage

        route: {
            params: {action, reportID, transactionID, backTo},
        },
    ...
    const isDraft = action === CONST.IOU.ACTION.CREATE;
    ...
        Navigation.goBack(isDraft && backTo || ROUTES.HOME);
    ...
        const updateCategory = (category) => {
            if (category.searchText === transaction.category) {
                IOU.resetMoneyRequestCategory_temporaryForRefactor(transactionID);
            } else {
                IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, category.searchText, isDraft);
            }
            if(!isDraft && category.searchText !== transaction.category){
                IOU.updateMoneyRequestCategory(transaction.transactionID, reportID, category.searchText);
            }
            navigateBack();
        };
    
  3. Update setMoneyRequestCategory_temporaryForRefactor to use isDraft :

    ...
     * @param {Boolean} isDraft - Indicates whether it's a draft or not
     */
    function setMoneyRequestCategory_temporaryForRefactor(transactionID, category, isDraft) {
        const key = isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION;
        Onyx.merge(`${key}${transactionID}`, { category });
    }
    

What alternative solutions did you explore? (Optional)

N/A

Copy link

melvin-bot bot commented Jan 24, 2024

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

@dukenv0307
Copy link
Contributor

Updated proposal to remove EditRequestCategoryPage

Copy link

melvin-bot bot commented Jan 30, 2024

@amyevans @anmurali @DylanDylann this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

Copy link

melvin-bot bot commented Jan 30, 2024

📣 @dukenv0307 🎉 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 📖

@dukenv0307
Copy link
Contributor

@DylanDylann The PR is ready for review.

@amyevans
Copy link
Contributor

How's the review stage coming along @dukenv0307 @DylanDylann? Seems like progress might be a little stagnant, @dukenv0307 can you address @DylanDylann's feedback from last week in the PR? Thanks!

@dukenv0307
Copy link
Contributor

I will update after returning from the traditional holiday on the 15th.

@anmurali anmurali removed the Bug Something is broken. Auto assigns a BugZero manager. label Feb 16, 2024
@anmurali anmurali removed their assignment Feb 16, 2024
@anmurali anmurali added the Bug Something is broken. Auto assigns a BugZero manager. label Feb 16, 2024
Copy link

melvin-bot bot commented Feb 16, 2024

Triggered auto assignment to @stephanieelliott (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Feb 16, 2024
@anmurali
Copy link

Rotating for backup during my OOO till Feb 29th

@anmurali anmurali self-assigned this Feb 16, 2024
@stephanieelliott
Copy link
Contributor

PR is being actively reviewed

@stephanieelliott
Copy link
Contributor

PR was deployed to staging a few hours ago!

Copy link

melvin-bot bot commented Feb 28, 2024

⚠️ 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.

@stephanieelliott
Copy link
Contributor

This was deployed to prod on 2/28, seems the automation didn't work so am updating manually

@stephanieelliott stephanieelliott changed the title [$250] Remove MoneyRequestCategoryPage.js and copy any changes since Nov 27 into IOURequestStepCategory.js [HOLD for payment 2024-03-04] [$250] Remove MoneyRequestCategoryPage.js and copy any changes since Nov 27 into IOURequestStepCategory.js Mar 5, 2024
@stephanieelliott
Copy link
Contributor

Summarizing payment on this issue:

Upwork job is here: https://www.upwork.com/jobs/~01aa1b22b861ac0e42

Copy link

melvin-bot bot commented Mar 11, 2024

⚠️ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests