Skip to content

[Due for payment 2025-05-22] [$250] Add Custom field 1 and Custom field 2 in the workspace member profile. #59243

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
JmillsExpensify opened this issue Mar 27, 2025 · 30 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production External Added to denote the issue can be worked on by a contributor Monthly KSv2 NewFeature Something to build that is a new item.

Comments

@JmillsExpensify
Copy link

JmillsExpensify commented Mar 27, 2025

Within the Onyx data for a given policy (e.g. "policy_XXXX"), specifically the employeeList, we have two data points that we're not yet exposing in the NewDot frontend. These are:

  • employeeUserId e.g. custom field 1
  • employeePayrollId e.g. custom field 2

If you aren't seeing these in your NewDot Onyx data, then:

  • Go to OldDot
  • Create a Control policy
  • Add some members
  • Click on the Settings for one of the members. Add data in custom field 1 and custom field 2

At that point the data will appear in your NewDot Onyx data.

Within the NewDot front-end, we'd like to expose these two data points in the following manner:

  • Add two push rows for Custom field 1 and Custom field 2
  • We'll accept any text in these fields. No form validation is required
  • Like any other push row, when the row contains data, we show the row label in addition to the data.

I'm including mocks to help make all this clear.

Image

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021905309034266716346
  • Upwork Job ID: 1905309034266716346
  • Last Price Increase: 2025-04-03
  • Automatic offers:
    • FitseTLT | Contributor | 106827215
Issue OwnerCurrent Issue Owner: @francoisl
@JmillsExpensify JmillsExpensify added Daily KSv2 NewFeature Something to build that is a new item. labels Mar 27, 2025
@JmillsExpensify JmillsExpensify self-assigned this Mar 27, 2025
@JmillsExpensify JmillsExpensify added the External Added to denote the issue can be worked on by a contributor label Mar 27, 2025
Copy link

melvin-bot bot commented Mar 27, 2025

Current assignee @JmillsExpensify is eligible for the NewFeature assigner, not assigning anyone new.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Mar 27, 2025
@melvin-bot melvin-bot bot changed the title Add Custom field 1 and Custom field 2 in the workspace member profile. [$250] Add Custom field 1 and Custom field 2 in the workspace member profile. Mar 27, 2025
Copy link

melvin-bot bot commented Mar 27, 2025

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

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

melvin-bot bot commented Mar 27, 2025

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Mar 27, 2025
@FitseTLT
Copy link
Contributor

FitseTLT commented Mar 27, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-03-27 18:03:23 UTC.

Proposal

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

Add Custom field 1 and Custom field 2 in the workspace member profile.

What is the root cause of that problem?

New Feature

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

We will add two push rows MenuItemWithTopDescription below role menu here

<View style={styles.w100}>
<MenuItemWithTopDescription
disabled={isSelectedMemberOwner || isSelectedMemberCurrentUser}
title={translate(`workspace.common.roleName`, {role: member?.role})}
description={translate('common.role')}
shouldShowRightIcon
onPress={openRoleSelectionModal}

For both custom fields in employeeList: employeeUserId, employeePayrollId, Passing the appropriate description and title (which would be the value of the field)

For setting the custom fields we can either create a new page/screen (and route) like the WorkspaceOverviewDescriptionPage page then we will navigate to that new route on press of this menu item
The page will have a form with one text input without any validation and onConfirm we will call a new util that will set the policy employeeList[member]'s corresponding customField optimistically and send the appropriate API request with appropriate params like policyID and new value and navigate back to members details page.

We can utilize the same screen for both cases via a param and we will accordingly display the correct placeholder, header text so on and also update onConfirm the corresponding field according to the param. So in that case we will navigate to the route with appropriate param on press of the push inputs.

We can also alternatively implement it via a modal like WorkspaceMemberDetailsRoleSelectionModal in which case we will only need to set modal visibility on Press on the menu. We can also utilize the same modal for both by passing the current customField to be modified as a prop.

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

If needed we can add a unit test for the new util we will use to set the custom fields.

What alternative solutions did you explore? (Optional)

@nkdengineer
Copy link
Contributor

Proposal

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

Add Custom field 1 and Custom field 2 in the workspace member profile.

What is the root cause of that problem?

New feature

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

Test branch: https://github.com/nkdengineer/App/tree/fix/59243

  1. Create a new page MemberCustomFieldPage. This page will have policyID, accountID, and fieldID params. On this page, we will have a Form with a single input. Submit the form will call the API to update the member custom field, we will handle optimistic data, success data, and failure data with offline parttern accordingly.
function updateMemberCustomField(policyID: string, accountID: number, fieldID: 'employeeUserID' | 'employeePayrollID', value: string) {
    const memberLogin = allPersonalDetails?.[accountID]?.login ?? '';
    const policy = getPolicy(policyID);
    const member = policy?.employeeList?.[memberLogin];

    const optimisticData: OnyxUpdate[] = [
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
            value: {employeeList: {[memberLogin]: {[fieldID]: value, pendingFields: {[fieldID]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}}}},
        },
    ];

    const successData: OnyxUpdate[] = [
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
            value: {employeeList: {[memberLogin]: {[fieldID]: value, pendingFields: {[fieldID]: null}}}},
        },
    ];

    const failureData: OnyxUpdate[] = [
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
            value: {employeeList: {[memberLogin]: {[fieldID]: member?.[fieldID], pendingFields: {[fieldID]: null}}}},
        },
    ];

    API.write(WRITE_COMMANDS.UPDATE_WORKSPACE_MEMBERS_CUSTOM_FIELD, {policyID, employees: JSON.stringify([{email: memberLogin, role: member?.role}])}, {optimisticData, successData, failureData});
}

  1. On WorkspaceMemberDetailsPage, add two rows for Custom field 1 and Custom field 2. The title is the value of this field, and the description is the name of the field. These rows should be wrapped in OfflineWithFeedback and click on the row will navigate to the MemberCustomFieldPage
<OfflineWithFeedback pendingAction={member?.pendingFields?.employeeUserID}>
    <MenuItemWithTopDescription
        title={member.employeeUserID}
        description={translate('workspace.common.employeeUserID')}
    shouldShowRightIcon
        onPress={() => {
            Navigation.navigate(ROUTES.WORKSPACE_MEMBER_CUSTOM_FIELD.getRoute(policyID, accountID, 'employeeUserID'));
        }}
    />
</OfflineWithFeedback>
<OfflineWithFeedback pendingAction={member?.pendingFields?.employeePayrollID}>
    <MenuItemWithTopDescription
        title={member.employeePayrollID}
        description={translate('workspace.common.employeePayrollID')}
        shouldShowRightIcon
        onPress={() => {
            Navigation.navigate(ROUTES.WORKSPACE_MEMBER_CUSTOM_FIELD.getRoute(policyID, accountID, 'employeePayrollID'));
        }}
    />
</OfflineWithFeedback>

  1. Other improvements can be done in the PR

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

We can add unit test for updateMemberCustomField function and verify that the data is correct.

What alternative solutions did you explore? (Optional)

Result

Screen.Recording.2025-03-31.at.16.16.31.mov

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.

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

melvin-bot bot commented Mar 31, 2025

@rayane-d Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@flaviadefaria flaviadefaria moved this to Second Cohort - MEDIUM or LOW in [#whatsnext] #migrate Mar 31, 2025
@rayane-d
Copy link
Contributor

rayane-d commented Apr 1, 2025

will review soon

@melvin-bot melvin-bot bot removed the Overdue label Apr 1, 2025
@JmillsExpensify
Copy link
Author

Yes, please! We'd like to get this in product this month.

Copy link

melvin-bot bot commented Apr 3, 2025

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

Copy link

melvin-bot bot commented Apr 7, 2025

@rayane-d Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added the Overdue label Apr 7, 2025
@JmillsExpensify
Copy link
Author

@rayane-d can you please prioritize this today?

@rayane-d
Copy link
Contributor

rayane-d commented Apr 7, 2025

Will do

@melvin-bot melvin-bot bot removed the Overdue label Apr 7, 2025
@rayane-d
Copy link
Contributor

rayane-d commented Apr 7, 2025

If you aren't seeing these in your NewDot Onyx data, then:

  • Go to OldDot
  • Create a Control policy
  • Add some members
  • Click on the Settings for one of the members. Add data in custom field 1 and custom field 2
  • At that point the data will appear in your NewDot Onyx data.

Confirmed that the needed data is available in NewDot Onyx data 👍

Image Image

@francoisl
Copy link
Contributor

Yes, we'll want to create a new API command like UpdateWorkspaceMembersCustomField or something like that, to comply with our 1:1:1 philosophy. I'll aim to get it done this week.

Going to assign @FitseTLT for now but please keep in mind the backend changes aren't implemented yet. If you want to get started I'm thinking we'll go with a new command like so, but this is subject to change:

  • name: UpdateWorkspaceMembersCustomFields
  • parameters - similar to what we do with UpdateWorkspaceMembersRoleParams, we could do something like:
    • policyID
    • employees: would be passed as [{"email": "[email protected]", "customField1": "value", "customField2": "value"}], where customField1 and customField2 are optional, but at least one of them is required.

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

melvin-bot bot commented Apr 7, 2025

📣 @FitseTLT 🎉 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 the Overdue label Apr 10, 2025
@francoisl
Copy link
Contributor

Backend changes are almost complete, ETA early next week.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Apr 12, 2025
@rayane-d
Copy link
Contributor

Not overdue, @FitseTLT is working on this

@FitseTLT
Copy link
Contributor

PR drafted and waiting on BE changes. Also waiting on copy confirmation here

@JmillsExpensify
Copy link
Author

Thanks everyone for keeping up the momentum on this one.

@JmillsExpensify
Copy link
Author

Actively being worked on.

@JmillsExpensify JmillsExpensify added Weekly KSv2 and removed Daily KSv2 labels Apr 16, 2025
@melvin-bot melvin-bot bot removed the Overdue label Apr 16, 2025
@francoisl
Copy link
Contributor

@FitseTLT the backend changes are now live on staging.

The API command name is UpdatePolicyMembersCustomFields (and not UpdateWorkspaceMembersRoleParams as I previously suggested — this is to stay consistent with our other existing API command names)

It needs a policyID and employees, in the format Array<{email: string; customField1?: string; customField2?: string}>. Let me know if you have any questions!

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

Hopefully get the last PR merged this week.

@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. @JmillsExpensify, @francoisl, @FitseTLT, @rayane-d 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!

@rayane-d
Copy link
Contributor

It appears that the automation did not work as intended. This was deployed to production 4 days ago #60277 (comment).

@francoisl francoisl changed the title [$250] Add Custom field 1 and Custom field 2 in the workspace member profile. [Due for payment 2025-05-22] [$250] Add Custom field 1 and Custom field 2 in the workspace member profile. May 19, 2025
@francoisl francoisl added Awaiting Payment Auto-added when associated PR is deployed to production and removed Reviewing Has a PR in review labels May 19, 2025
@JmillsExpensify
Copy link
Author

Payment summary:

Also don't forget the BZ checklist before requesting payment. We need a regression test for this.

@JmillsExpensify
Copy link
Author

Confirming that contributor has been paid via Upwork.

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 External Added to denote the issue can be worked on by a contributor Monthly KSv2 NewFeature Something to build that is a new item.
Projects
Status: Second Cohort - MEDIUM or LOW
Development

No branches or pull requests

5 participants