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

[$250] Remove MoneyRequestDatePage.js and copy any changes since Nov 27 into IOURequestStepDate.js #34608

Closed
Tracked by #29107
tgolen opened this issue Jan 16, 2024 · 39 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: MoneyRequestDatePage
New Component IOURequestStepDate

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/~0155d041c50cef598e
  • Upwork Job ID: 1747632794805731328
  • Last Price Increase: 2024-01-24
  • Automatic offers:
    • DylanDylann | Contributor | 28130672
    • brunovjk | Contributor | 28132561
@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 @muttmuure (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@Krishna2323
Copy link
Contributor

Krishna2323 commented Jan 16, 2024

Proposal

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

Remove MoneyRequestDatePage.js and copy any changes since Nov 27 into IOURequestStepDate.js

What is the root cause of that problem?

Component update

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

I checked all the commits after 27th Nov and the new component is updated according to the old component, we just need to remove the file and route created for it. I checked the commits thoroughly but will check again in the PR. There are total 7 commits after 27th Nov in the old component and most of them are about renaming constants and DatePicker component and imports.

Component to remove:
https://github.com/Expensify/App/blob/main/src/pages/iou/MoneyRequestDatePage.js

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

We also need to remove all traces from src/libs/Navigation/types.ts & src/libs/Navigation/linkingConfig.ts

[SCREENS.MONEY_REQUEST.DATE]: ROUTES.MONEY_REQUEST_DATE.route,

[SCREENS.MONEY_REQUEST.DATE]: {

Note: The below 2 steps can be omitted because we only use IOURequestStepDate for IOU creation flow.

Need to update to :action here:

route: 'create/:iouType/date/:transactionID/:reportID',

Need to pass the action here:

Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()));

Result

@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 MoneyRequestDatePage.js and copy any changes since Nov 27 into IOURequestStepDate.js [$500] Remove MoneyRequestDatePage.js and copy any changes since Nov 27 into IOURequestStepDate.js Jan 17, 2024
Copy link

melvin-bot bot commented Jan 17, 2024

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

Copy link

melvin-bot bot commented Jan 17, 2024

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

@ghost
Copy link

ghost commented Jan 17, 2024

I want to work on it

@ishpaul777
Copy link
Contributor

Would love to work on this

@ghost
Copy link

ghost commented Jan 17, 2024

Proposal

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

Remove MoneyRequestDatePage.js and copy any changes since Nov 27 into IOURequestStepDate.js

What is the root cause of that problem?

The main changes are in the DatePicker that has been added in the old component after 27th November 2023,

<InputWrapper
InputComponent={DatePicker}
inputID="moneyRequestCreated"

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

In the new component i.e. here https://github.com/Expensify/App/blob/main/src/pages/iou/request/IOURequestStartPage.js, we will add DatePicker and update the component accordingly.

@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 MoneyRequestDatePage.js and copy any changes since Nov 27 into IOURequestStepDate.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/blob/main/src/pages/iou/MoneyRequestDatePage.js

We have had some changes since Nov 27, 2023 but it's the refactor change and has already been applied in IOURequestStepDate. So no need to change here.

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

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

We only need to remove MoneyRequestDatePage in ModalStackNavigators, remove .MONEY_REQUEST.DATE from SCREENS, and remove MONEY_REQUEST_DATE route

[SCREENS.MONEY_REQUEST.DATE]: () => require('../../../pages/iou/MoneyRequestDatePage').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}/date/${transactionID}/${reportID}`, backTo),

App/src/ROUTES.ts

Lines 339 to 340 in a8acf44

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

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

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

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

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

What alternative solutions did you explore? (Optional)

NA

@mountiny mountiny changed the title [$500] Remove MoneyRequestDatePage.js and copy any changes since Nov 27 into IOURequestStepDate.js [$250] Remove MoneyRequestDatePage.js and copy any changes since Nov 27 into IOURequestStepDate.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
@Krishna2323
Copy link
Contributor

Proposal Updated

Added a note about why should we not include the action param.

@sobitneupane
Copy link
Contributor

@muttmuure I won't be able to review proposals before weekend. Please feel free to reassign the issue if it is urgent.

@melvin-bot melvin-bot bot removed the Overdue label Jan 24, 2024
@DylanDylann
Copy link
Contributor

@muttmuure I have context with this Epic in here. I am happy to take this one as a C+ contributor

@dukenv0307
Copy link
Contributor

Updated proposal to remove EditRequestDatePage.

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? 💸

@brunovjk
Copy link
Contributor

brunovjk commented Jan 24, 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 MoneyRequestDatePage and EditRequestCreatedPage to IOURequestStepDate. 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. Checked the 7 commits made to the MoneyRequestDatePage component since 27-Nov. IOURequestStepDate is already updated with those changes. This way there will be no need to arrange any changes from MoneyRequestDatePage to be transferred to IOURequestStepDate

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 MoneyRequestDatePage component along with:

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

  2. The new component uses STEP_DATE and has it own linkingConfig, SCREENS and ROUTES already configured, we must remove DATE 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 Type navigation according to new route and getRoute.
    to
        [SCREENS.MONEY_REQUEST.STEP_DATE]: {
            iouType: string;
            transactionID: string;
            reportID: string;
            backTo: string;
        };
    
  2. Update route and getRoute to use the new :action param.
        MONEY_REQUEST_STEP_DATE: {
            route: ':action/:iouType/date/:transactionID/:reportID?',
            getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
                getUrlWithBackToParam(`${action}/${iouType}/date/${transactionID}/${reportID}`, backTo),
        }, 
    
  3. Add CONST.IOU.ACTION.CREATE at MoneyTemporaryForRefactorRequestConfirmationList to follow ROUTES.MONEY_REQUEST_STEP_DATE changes.
    Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.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_DATE changes.

    Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.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 IOURequestStepDate.js to accommodate the CREATE, EDIT and SPLIT_EDIT of the Date field. We need to use IOU.updateMoneyRequestDate as was done in EditRequestPage and setDraftSplitTransaction like EditSplitBillPage. Something like:

        route: {
            params: {iouType, action, reportID, transactionID, backTo},
        },
    ...
    const isDraft = action === CONST.IOU.ACTION.CREATE;
    ...
        Navigation.goBack(isDraft && backTo || ROUTES.HOME);
    ...
    const updateDate = (value) => {
        const newDate = value.moneyRequestCreated.trim();
        if (newDate === transaction.created) {
            navigateBack();
            return;
        }
        if (iouType === CONST.IOU.TYPE.SPLIT && action === CONST.IOU.ACTION.EDIT) {
            IOU.setDraftSplitTransaction(transaction.transactionID, {newDate});
            navigateBack();
            return;
        }
        IOU.setMoneyRequestCreated_temporaryForRefactor(transactionID, newDate, isDraft);
    
        if (action === CONST.IOU.ACTION.EDIT) {
            IOU.updateMoneyRequestDate(transactionID, reportID, newDate);
        }
        navigateBack();
    };
    
  3. Update setMoneyRequestCreated_temporaryForRefactor to use isDraft :

    ...
     * @param {Boolean} isDraft - Indicates whether it's a draft or not
     */
    function setMoneyRequestCreated_temporaryForRefactor(transactionID, created, isDraft) {
        const key = isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION;
        Onyx.merge(`${key}${transactionID}`, {created});
    }
    
  4. We need to remove any related EDIT_SPLIT_BILL.getRoute

    Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(reportID, reportActionID, CONST.EDIT_REQUEST_FIELD.DATE));

Note: At the PR we double check all (ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(... and EDIT_SPLIT_BILL.getRoute used at Date/Created flow.

What alternative solutions did you explore? (Optional)

N/A

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

melvin-bot bot commented Jan 29, 2024

@sobitneupane, @muttmuure Huh... This is 4 days overdue. Who can take care of this?

Copy link

melvin-bot bot commented Jan 31, 2024

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

@brunovjk
Copy link
Contributor

brunovjk commented Jan 31, 2024

@brunovjk's proposal cover all cases

thank you @DylanDylann, It looks like you copied the link to my proposal wrong hehe Anyway, I'm going to start working on the PR for review

@DylanDylann
Copy link
Contributor

DylanDylann commented Jan 31, 2024

It looks like you copied the link to my proposal wrong hehe

Thanks. Updated 😄

@DylanDylann
Copy link
Contributor

@brunovjk Please wait to be assigned official before implementing PR

@brunovjk
Copy link
Contributor

@brunovjk Please wait to be assigned official before implementing PR

Nice! Thanks!!!

Copy link

melvin-bot bot commented Jan 31, 2024

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

@tgolen
Copy link
Contributor Author

tgolen commented Jan 31, 2024

@brunovjk I think these changes also need to be included in your PR:

  • Remove IOU.setMoneyRequestCreated() and all references
  • Rename IOU.setMoneyRequestCreated_temporaryForRefactor() to IOU.setMoneyRequestCreated()

@brunovjk
Copy link
Contributor

Im on it @tgolen, thank you. PR will be ready for review by 07/02

@DylanDylann
Copy link
Contributor

@brunovjk Please raise a PR soon

@melvin-bot melvin-bot bot removed the Overdue label Feb 5, 2024
@brunovjk
Copy link
Contributor

brunovjk commented Feb 5, 2024

@DylanDylann I'm working on it right now, but I'm having a problem with 'edit/split'. In your PRs ( #35641 and #35137) I saw that you 'hard coded' the 'ioutype' in MoneyRequestView.tsx:

getRoute(
                                         CONST.IOU.ACTION.EDIT,
                                         CONST.IOU.TYPE.REQUEST,

I thought that we needed to pass a dynamic iouType. Like we do it at MoneyTemporaryForRefactorRequestConfirmationList.

/create/request/date/, /edit/request/date/ and /create/split/date/ works fine. I'm 100% into it now, as soon I get the /edit/split/date/ I will raise the PR.

@DylanDylann
Copy link
Contributor

As I know MoneyRequestView.tsx is only used for REQUEST flow, and isn't used in SPLIT_BILL flow. It is the reason why I hardcoded CONST.IOU.TYPE.REQUEST

@brunovjk
Copy link
Contributor

brunovjk commented Feb 5, 2024

Awesome! Thank you :D

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Feb 5, 2024
@brunovjk
Copy link
Contributor

brunovjk commented Feb 5, 2024

@DylanDylann The PR is ready for review, but I found a bug, also reproduced on 'staging' that I believe needs to be resolved so that the 'date' flow is perfect, I didn't find a related issue. In PR I bring more information.

@DylanDylann
Copy link
Contributor

DylanDylann commented Feb 20, 2024

@muttmuure The PR was deployed to production 5 days ago. It seems the automation bot doesn't work on this issue. Please help to move forward this one

@brunovjk
Copy link
Contributor

@muttmuure 👉👈

@muttmuure muttmuure added Daily KSv2 and removed Weekly KSv2 labels Feb 27, 2024
@muttmuure
Copy link
Contributor

All paid up

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

9 participants