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] Refactor getTrackExpenseInformation to use a parameter object #57190

Open
neil-marcellini opened this issue Feb 20, 2025 · 11 comments
Open
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@neil-marcellini
Copy link
Contributor

neil-marcellini commented Feb 20, 2025

As part of the tracking issue, and as advised in its description, refactor getTrackExpenseInformation to use a parameter object.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021892615722799321204
  • Upwork Job ID: 1892615722799321204
  • Last Price Increase: 2025-02-20
Issue OwnerCurrent Issue Owner: @s77rt
@neil-marcellini neil-marcellini added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor labels Feb 20, 2025
@neil-marcellini neil-marcellini self-assigned this Feb 20, 2025
Copy link

melvin-bot bot commented Feb 20, 2025

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

@melvin-bot melvin-bot bot changed the title Refactor getTrackExpenseInformation to use a parameter object [$250] Refactor getTrackExpenseInformation to use a parameter object Feb 20, 2025
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 20, 2025
Copy link

melvin-bot bot commented Feb 20, 2025

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

Copy link

melvin-bot bot commented Feb 20, 2025

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

@mkzie2
Copy link
Contributor

mkzie2 commented Feb 20, 2025

Proposal

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

Refactor convertTrackedExpenseToRequest function to use a parameter object

What is the root cause of that problem?

This is an improvement

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

Wrap all parameters of this function into one object and in this object, we can have some sub-objects that will wrap the related data.

function getTrackExpenseInformation(

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

None

What alternative solutions did you explore? (Optional)

@mkzie2
Copy link
Contributor

mkzie2 commented Feb 20, 2025

@neil-marcellini Please assign me.

@KALU-c
Copy link

KALU-c commented Feb 20, 2025

Proposal

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

The getTrackExpenseInformation function has too many parameters, making it hard to read, maintain, and update.

What is the root cause of that problem?

The function takes too many separate arguments instead of a single object, making it harder to read and manage.

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

Change getTrackExpenseInformation to take one object instead of a long list of arguments.

App/src/libs/actions/IOU.ts

Lines 3079 to 3101 in 32cfa66

function getTrackExpenseInformation(
parentChatReport: OnyxEntry<OnyxTypes.Report>,
participant: Participant,
comment: string,
amount: number,
currency: string,
created: string,
merchant: string,
receipt: OnyxEntry<Receipt>,
category: string | undefined,
tag: string | undefined,
taxCode: string | undefined,
taxAmount: number | undefined,
billable: boolean | undefined,
policy: OnyxEntry<OnyxTypes.Policy> | undefined,
policyTagList: OnyxEntry<OnyxTypes.PolicyTagLists> | undefined,
policyCategories: OnyxEntry<OnyxTypes.PolicyCategories> | undefined,
payeeEmail = currentUserEmail,
payeeAccountID = userAccountID,
moneyRequestReportID = '',
linkedTrackedExpenseReportAction?: OnyxTypes.ReportAction,
existingTransactionID?: string,
): TrackExpenseInformation | null {

Also, update all function calls to use the new object format.

App/src/libs/actions/IOU.ts

Lines 4821 to 4845 in 32cfa66

getTrackExpenseInformation(
currentChatReport,
participant,
comment,
amount,
currency,
created,
merchant,
trackedReceipt,
category,
tag,
taxCode,
taxAmount,
billable,
policy,
policyTagList,
policyCategories,
payeeEmail,
payeeAccountID,
moneyRequestReportID,
linkedTrackedExpenseReportAction,
isMovingTransactionFromTrackExpense && linkedTrackedExpenseReportAction && isMoneyRequestAction(linkedTrackedExpenseReportAction)
? getOriginalMessage(linkedTrackedExpenseReportAction)?.IOUTransactionID
: undefined,
) ?? {};

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

None

What alternative solutions did you explore? (Optional)

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 Feb 20, 2025

📣 @KALU-c! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@KALU-c
Copy link

KALU-c commented Feb 20, 2025

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~01154410394d30729e

Copy link

melvin-bot bot commented Feb 20, 2025

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@s77rt
Copy link
Contributor

s77rt commented Feb 20, 2025

@mkzie2 @KALU-c Thank you for the proposals. Given that this is a straightforward change we'd go with the first proposal i.e. @mkzie2 `s

🎀 👀 🎀 C+ reviewed
Link to proposal

Copy link

melvin-bot bot commented Feb 20, 2025

Current assignee @neil-marcellini is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

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 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

5 participants