Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.5k stars 2.85k forks source link

[$250] Migrate MoneyRequestConfirmationList to useOnyx #50532

Open neil-marcellini opened 2 weeks ago

neil-marcellini commented 2 weeks ago

Problem

In this PR I made some changes to MoneyRequestConfirmationList, which trigged the ESLint changed files check to error saying that we need to migrate withOnyx to useOnyx

Solution migrate to useOnyx

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021844152421070937252
  • Upwork Job ID: 1844152421070937252
  • Last Price Increase: 2024-10-09
  • Automatic offers:
    • shubham1206agra | Reviewer | 104434485
    • NJ-2020 | Contributor | 104434486
Issue OwnerCurrent Issue Owner: @shubham1206agra
melvin-bot[bot] commented 2 weeks ago

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

melvin-bot[bot] commented 2 weeks ago

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

melvin-bot[bot] commented 2 weeks ago

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

Shahidullah-Muffakir commented 2 weeks ago

Proposal

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

We are trying to migrate the MoneyRequestConfirmationList component from using the withOnyx HOC to the useOnyx hook.

What is the root cause of that problem?

The current implementation uses withOnyx, which is an older pattern for connecting components to Onyx data.

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

In this file: https://github.com/Expensify/App/blob/bfdd19ba851376b012fbcee112637414736a0fbd/src/components/MoneyRequestConfirmationList.tsx#L82

  1. Remove the withOnyx HOC from the MoneyRequestConfirmationList component.
  2. Add the useOnyx hook inside the MoneyRequestConfirmationList component to fetch these data:

https://github.com/Expensify/App/blob/bfdd19ba851376b012fbcee112637414736a0fbd/src/components/MoneyRequestConfirmationList.tsx#L978-L983

NJ-2020 commented 2 weeks ago

Proposal

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

Migrate MoneyRequestConfirmationList to useOnyx

What is the root cause of that problem?

N/A

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

Change from withOnyx here: https://github.com/Expensify/App/blob/bfdd19ba851376b012fbcee112637414736a0fbd/src/components/MoneyRequestConfirmationList.tsx#L978-L1008 to useOnyx:

const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID || '-1'}`);
const [policyCategoriesDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES_DRAFT}${policyID || '-1'}`);
const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID || '-1'}`);
const [defaultMileageRate] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID || '-1'}`, {
    selector: DistanceRequestUtils.getDefaultMileageRate,
});
const [mileageRatesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID || '-1'}`, {
    selector: (policy: OnyxEntry<OnyxTypes.Policy>) => DistanceRequestUtils.getMileageRates(policy),
});
const [policyReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID || '-1'}`);
const [policyDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyID || '-1'}`);
const [lastSelectedDistanceRates] = useOnyx(ONYXKEYS.NVP_LAST_SELECTED_DISTANCE_RATES);
const [currencyList] = useOnyx(ONYXKEYS.CURRENCY_LIST);

And remove the MoneyRequestConfirmationListOnyxProps type https://github.com/Expensify/App/blob/bfdd19ba851376b012fbcee112637414736a0fbd/src/components/MoneyRequestConfirmationList.tsx#L82 https://github.com/Expensify/App/blob/bfdd19ba851376b012fbcee112637414736a0fbd/src/components/MoneyRequestConfirmationList.tsx#L53-L57

And the parameters from the function And also remove this https://github.com/Expensify/App/blob/bfdd19ba851376b012fbcee112637414736a0fbd/src/components/MoneyRequestConfirmationList.tsx#L1038-L1039 https://github.com/Expensify/App/blob/bfdd19ba851376b012fbcee112637414736a0fbd/src/components/MoneyRequestConfirmationList.tsx#L1041

What alternative solutions did you explore? (Optional)

melvin-bot[bot] commented 2 weeks ago

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

abekkala commented 2 weeks ago

@anmurali I'll be ooo until Mon Oct 21; then I can take this back.

STATUS: proposals have been posted, waiting on one to be chosen

melvin-bot[bot] commented 1 week ago

@abekkala, @anmurali, @neil-marcellini, @shubham1206agra Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

neil-marcellini commented 1 week ago

I like @NJ-2020's proposal best so far since it's sufficiently detailed while the one before it was not quite detailed enough. Hiring! @shubham1206agra please try to review proposals more promptly next time or re-assign.

melvin-bot[bot] commented 1 week ago

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

Offer link Upwork job

melvin-bot[bot] commented 1 week ago

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

NJ-2020 commented 1 week ago

PR ready

cc: @shubham1206agra

abekkala commented 4 days ago

I'm back from ooo - unassinging @anmurali

abekkala commented 4 days ago

PR not yet deployed

Fix: @NJ-2020 PR Review: @shubham1206agra