Skip to content

Fix - Add Custom field 1 and Custom field 2 in the workspace member profile. #60277

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

Merged
merged 19 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ const CONST = {
TASK_TITLE_DISABLED_RULES: ['image'],
// Note: Group and Self-DM excluded as these are not tied to a Workspace
WORKSPACE_ROOM_TYPES: [chatTypes.POLICY_ADMINS, chatTypes.POLICY_ANNOUNCE, chatTypes.DOMAIN_ALL, chatTypes.POLICY_ROOM, chatTypes.POLICY_EXPENSE_CHAT, chatTypes.INVOICE],
CUSTOM_FIELD_KEYS: {customField1: 'employeeUserID', customField2: 'employeePayrollID'},
ANDROID_PACKAGE_NAME,
WORKSPACE_ENABLE_FEATURE_REDIRECT_DELAY: 100,
ANIMATED_HIGHLIGHT_ENTRY_DELAY: 50,
Expand Down
3 changes: 3 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,8 @@ const ONYXKEYS = {
WORKSPACE_TAG_FORM_DRAFT: 'workspaceTagFormDraft',
WORKSPACE_SETTINGS_FORM_DRAFT: 'workspaceSettingsFormDraft',
WORKSPACE_DESCRIPTION_FORM: 'workspaceDescriptionForm',
WORKSPACE_MEMBER_CUSTOM_FIELD_FORM: 'WorkspaceMemberCustomFieldForm',
WORKSPACE_MEMBER_CUSTOM_FIELD_FORM_DRAFT: 'WorkspaceMemberCustomFieldFormDraft',
WORKSPACE_DESCRIPTION_FORM_DRAFT: 'workspaceDescriptionFormDraft',
WORKSPACE_TAX_CUSTOM_NAME: 'workspaceTaxCustomName',
WORKSPACE_TAX_CUSTOM_NAME_DRAFT: 'workspaceTaxCustomNameDraft',
Expand Down Expand Up @@ -880,6 +882,7 @@ type OnyxFormValuesMapping = {
[ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM]: FormTypes.ReimbursementAccountForm;
[ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT_FORM]: FormTypes.PersonalBankAccountForm;
[ONYXKEYS.FORMS.WORKSPACE_DESCRIPTION_FORM]: FormTypes.WorkspaceDescriptionForm;
[ONYXKEYS.FORMS.WORKSPACE_MEMBER_CUSTOM_FIELD_FORM]: FormTypes.WorkspaceMemberCustomFieldsForm;
[ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS]: FormTypes.AdditionalDetailStepForm;
[ONYXKEYS.FORMS.POLICY_TAG_NAME_FORM]: FormTypes.PolicyTagNameForm;
[ONYXKEYS.FORMS.WORKSPACE_NEW_TAX_FORM]: FormTypes.WorkspaceNewTaxForm;
Expand Down
5 changes: 5 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Log from './libs/Log';
import type {ReimbursementAccountStepToOpen} from './libs/ReimbursementAccountUtils';
import type {ExitReason} from './types/form/ExitSurveyReasonForm';
import type {ConnectionName, SageIntacctMappingName} from './types/onyx/Policy';
import type {CustomFieldType} from './types/onyx/PolicyEmployee';
import type AssertTypesNotEqual from './types/utils/AssertTypesNotEqual';

// This is a file containing constants for all the routes we want to be able to go to
Expand Down Expand Up @@ -1512,6 +1513,10 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/members/:accountID',
getRoute: (policyID: string, accountID: number) => `settings/workspaces/${policyID}/members/${accountID}` as const,
},
WORKSPACE_CUSTOM_FIELDS: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WORKSPACE_CUSTOM_FIELDS: {
WORKSPACE_MEMBER_CUSTOM_FIELDS: {

route: 'settings/workspaces/:policyID/members/:accountID/:customFieldType',
getRoute: (policyID: string, accountID: number, customFieldType: CustomFieldType) => `/settings/workspaces/${policyID}/members/${accountID}/${customFieldType}` as const,
},
WORKSPACE_MEMBER_NEW_CARD: {
route: 'settings/workspaces/:policyID/members/:accountID/new-card',
getRoute: (policyID: string, accountID: number) => `settings/workspaces/${policyID}/members/${accountID}/new-card` as const,
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ const SCREENS = {
CATEGORIES_IMPORTED: 'Categories_Imported',
MORE_FEATURES: 'Workspace_More_Features',
MEMBER_DETAILS: 'Workspace_Member_Details',
MEMBER_CUSTOM_FIELD: 'Workspace_Member_Custom_Field',
MEMBER_NEW_CARD: 'Workspace_Member_NewCard',
OWNER_CHANGE_CHECK: 'Workspace_Owner_Change_Check',
OWNER_CHANGE_SUCCESS: 'Workspace_Owner_Change_Success',
Expand Down
18 changes: 18 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ import type {
UnreportedTransactionParams,
UnshareParams,
UntilTimeParams,
UpdatedCustomFieldParams,
UpdatedPolicyCategoryNameParams,
UpdatedPolicyCategoryParams,
UpdatedPolicyCurrencyParams,
Expand Down Expand Up @@ -2910,6 +2911,9 @@ const translations = {
reimburse: 'Reimbursements',
categories: 'Categories',
tags: 'Tags',
customField1: 'Custom field 1',
customField2: 'Custom field 2',
customFieldHint: 'Add custom coding that applies to all spend from this member.',
reportFields: 'Report fields',
reportTitle: 'Report title',
reportField: 'Report field',
Expand Down Expand Up @@ -5441,6 +5445,20 @@ const translations = {
integrationSyncFailed: ({label, errorMessage}: IntegrationSyncFailedParams) => `failed to sync with ${label}${errorMessage ? ` ("${errorMessage}")` : ''}`,
addEmployee: ({email, role}: AddEmployeeParams) => `added ${email} as ${role === 'member' ? 'a' : 'an'} ${role}`,
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) => `updated the role of ${email} to ${newRole} (previously ${currentRole})`,
updatedCustomField1: ({email, previousValue, newValue}: UpdatedCustomFieldParams) => {
if (!newValue) {
return `removed ${email}'s custom field 1 (previously "${previousValue}")`;
}

return !previousValue ? `added "${newValue}" to ${email}’s custom field 1` : `changed ${email}’s custom field 1 to "${newValue}" (previously "${previousValue}")`;
},
updatedCustomField2: ({email, previousValue, newValue}: UpdatedCustomFieldParams) => {
if (!newValue) {
return `removed ${email}'s custom field 2 (previously "${previousValue}")`;
}

return !previousValue ? `added "${newValue}" to ${email}’s custom field 2` : `changed ${email}’s custom field 2 to "${newValue}" (previously "${previousValue}")`;
},
leftWorkspace: ({nameOrEmail}: LeftWorkspaceParams) => `${nameOrEmail} left the workspace`,
removeMember: ({email, role}: AddEmployeeParams) => `removed ${role} ${email}`,
removedConnection: ({connectionName}: ConnectionNameParams) => `removed connection to ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}`,
Expand Down
22 changes: 22 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ import type {
UnreportedTransactionParams,
UnshareParams,
UntilTimeParams,
UpdatedCustomFieldParams,
UpdatedPolicyCategoryNameParams,
UpdatedPolicyCategoryParams,
UpdatedPolicyCurrencyParams,
Expand Down Expand Up @@ -2936,6 +2937,9 @@ const translations = {
reimburse: 'Reembolsos',
categories: 'Categorías',
tags: 'Etiquetas',
customField1: 'Campo personalizado 1',
customField2: 'Campo personalizado 2',
customFieldHint: 'Añade una codificación personalizada que se aplique a todos los gastos de este miembro.',
reportFields: 'Campos de informe',
reportTitle: 'El título del informe.',
taxes: 'Impuestos',
Expand Down Expand Up @@ -5498,6 +5502,24 @@ const translations = {
integrationSyncFailed: ({label, errorMessage}: IntegrationSyncFailedParams) => `no se pudo sincronizar con ${label}${errorMessage ? ` ("${errorMessage}")` : ''}`,
addEmployee: ({email, role}: AddEmployeeParams) => `agregó a ${email} como ${role}`,
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) => `actualizó el rol ${email} a ${newRole} (previamente ${currentRole})`,
updatedCustomField1: ({email, previousValue, newValue}: UpdatedCustomFieldParams) => {
if (!newValue) {
return `eliminó el campo personalizado 1 de ${email} (previamente "${previousValue}")`;
}

return !previousValue
? `añadió "${newValue}" al campo personalizado 1 de ${email}`
: `cambió el campo personalizado 1 de ${email} a "${newValue}" (previamente "${previousValue}")`;
},
updatedCustomField2: ({email, previousValue, newValue}: UpdatedCustomFieldParams) => {
if (!newValue) {
return `eliminó el campo personalizado 2 de ${email} (previamente "${previousValue}")`;
}

return !previousValue
? `añadió "${newValue}" al campo personalizado 2 de ${email}`
: `cambió el campo personalizado 2 de ${email} a "${newValue}" (previamente "${previousValue}")`;
},
leftWorkspace: ({nameOrEmail}: LeftWorkspaceParams) => `${nameOrEmail} salió del espacio de trabajo`,
removeMember: ({email, role}: AddEmployeeParams) => `eliminado ${role} ${email}`,
removedConnection: ({connectionName}: ConnectionNameParams) => `eliminó la conexión a ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}`,
Expand Down
3 changes: 3 additions & 0 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ type AddEmployeeParams = {email: string; role: string};

type UpdateRoleParams = {email: string; currentRole: string; newRole: string};

type UpdatedCustomFieldParams = {email: string; previousValue: string; newValue: string};

type LeftWorkspaceParams = {nameOrEmail: string};

type RemoveMemberParams = {email: string; role: string};
Expand Down Expand Up @@ -894,6 +896,7 @@ export type {
IntegrationSyncFailedParams,
AddEmployeeParams,
UpdateRoleParams,
UpdatedCustomFieldParams,
LeftWorkspaceParams,
RemoveMemberParams,
DateParams,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type UpdatePolicyMembersCustomFieldsParams = {
policyID: string;
employees: string;
};

export default UpdatePolicyMembersCustomFieldsParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export type {default as OpenPolicyCategoriesPageParams} from './OpenPolicyCatego
export type {default as OpenPolicyTagsPageParams} from './OpenPolicyTagsPageParams';
export type {default as OpenDraftWorkspaceRequestParams} from './OpenDraftWorkspaceRequestParams';
export type {default as CreateWorkspaceFromIOUPaymentParams} from './CreateWorkspaceFromIOUPaymentParams';
export type {default as UpdatePolicyMembersCustomFieldsParams} from './UpdatePolicyMembersCustomFieldsParams';
export type {default as CreateTaskParams} from './CreateTaskParams';
export type {default as CancelTaskParams} from './CancelTaskParams';
export type {default as EditTaskAssigneeParams} from './EditTaskAssigneeParams';
Expand Down
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const WRITE_COMMANDS = {
UPDATE_WORKSPACE_MEMBERS_ROLE: 'UpdateWorkspaceMembersRole',
CREATE_WORKSPACE: 'CreateWorkspace',
CREATE_WORKSPACE_FROM_IOU_PAYMENT: 'CreateWorkspaceFromIOUPayment',
UPDATE_POLICY_MEMBERS_CUSTOM_FIELDS: 'UpdatePolicyMembersCustomFields',
SET_WORKSPACE_CATEGORIES_ENABLED: 'SetWorkspaceCategoriesEnabled',
MOVE_IOU_REPORT_TO_POLICY_AND_INVITE_SUBMITTER: 'MoveIOUReportToPolicyAndInviteSubmitter',
SET_POLICY_TAGS_ENABLED: 'SetPolicyTagsEnabled',
Expand Down Expand Up @@ -607,6 +608,7 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.UPDATE_WORKSPACE_MEMBERS_ROLE]: Parameters.UpdateWorkspaceMembersRoleParams;
[WRITE_COMMANDS.CREATE_WORKSPACE]: Parameters.CreateWorkspaceParams;
[WRITE_COMMANDS.CREATE_WORKSPACE_FROM_IOU_PAYMENT]: Parameters.CreateWorkspaceFromIOUPaymentParams;
[WRITE_COMMANDS.UPDATE_POLICY_MEMBERS_CUSTOM_FIELDS]: Parameters.UpdatePolicyMembersCustomFieldsParams;
[WRITE_COMMANDS.MOVE_IOU_REPORT_TO_EXISTING_POLICY]: Parameters.MoveIOUReportToExistingPolicyParams;
[WRITE_COMMANDS.SET_WORKSPACE_CATEGORIES_ENABLED]: Parameters.SetWorkspaceCategoriesEnabledParams;
[WRITE_COMMANDS.MOVE_IOU_REPORT_TO_POLICY_AND_INVITE_SUBMITTER]: Parameters.MoveIOUReportToPolicyAndInviteSubmitterParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.DOWNGRADE]: () => require<ReactComponentModule>('../../../../pages/workspace/downgrade/WorkspaceDowngradePage').default,
[SCREENS.WORKSPACE.PAY_AND_DOWNGRADE]: () => require<ReactComponentModule>('../../../../pages/workspace/downgrade/PayAndDowngradePage').default,
[SCREENS.WORKSPACE.MEMBER_DETAILS]: () => require<ReactComponentModule>('../../../../pages/workspace/members/WorkspaceMemberDetailsPage').default,
[SCREENS.WORKSPACE.MEMBER_CUSTOM_FIELD]: () => require<ReactComponentModule>('../../../../pages/workspace/members/WorkspaceMemberCustomFieldPage').default,
[SCREENS.WORKSPACE.MEMBER_NEW_CARD]: () => require<ReactComponentModule>('../../../../pages/workspace/members/WorkspaceMemberNewCardPage').default,
[SCREENS.WORKSPACE.OWNER_CHANGE_CHECK]: () => require<ReactComponentModule>('@pages/workspace/members/WorkspaceOwnerChangeWrapperPage').default,
[SCREENS.WORKSPACE.OWNER_CHANGE_SUCCESS]: () => require<ReactComponentModule>('../../../../pages/workspace/members/WorkspaceOwnerChangeSuccessPage').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const WORKSPACE_TO_RHP: Partial<Record<keyof WorkspaceSplitNavigatorParamList, s
],
[SCREENS.WORKSPACE.MEMBERS]: [
SCREENS.WORKSPACE.MEMBER_DETAILS,
SCREENS.WORKSPACE.MEMBER_CUSTOM_FIELD,
SCREENS.WORKSPACE.MEMBER_NEW_CARD,
SCREENS.WORKSPACE.OWNER_CHANGE_CHECK,
SCREENS.WORKSPACE.OWNER_CHANGE_SUCCESS,
Expand Down
3 changes: 3 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,9 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
[SCREENS.WORKSPACE.MEMBER_DETAILS]: {
path: ROUTES.WORKSPACE_MEMBER_DETAILS.route,
},
[SCREENS.WORKSPACE.MEMBER_CUSTOM_FIELD]: {
path: ROUTES.WORKSPACE_CUSTOM_FIELDS.route,
},
[SCREENS.WORKSPACE.MEMBER_NEW_CARD]: {
path: ROUTES.WORKSPACE_MEMBER_NEW_CARD.route,
},
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type SCREENS from '@src/SCREENS';
import type EXIT_SURVEY_REASON_FORM_INPUT_IDS from '@src/types/form/ExitSurveyReasonForm';
import type {CompanyCardFeed} from '@src/types/onyx';
import type {ConnectionName, SageIntacctMappingName} from '@src/types/onyx/Policy';
import type {CustomFieldType} from '@src/types/onyx/PolicyEmployee';
import type {SIDEBAR_TO_SPLIT} from './linkingConfig/RELATIONS';

type NavigationRef = NavigationContainerRefWithCurrent<RootNavigatorParamList>;
Expand Down Expand Up @@ -376,6 +377,11 @@ type SettingsNavigatorParamList = {
policyID: string;
accountID: string;
};
[SCREENS.WORKSPACE.MEMBER_CUSTOM_FIELD]: {
policyID: string;
accountID: string;
customFieldType: CustomFieldType;
};
[SCREENS.WORKSPACE.MEMBER_NEW_CARD]: {
policyID: string;
accountID: string;
Expand Down
15 changes: 13 additions & 2 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1891,12 +1891,23 @@ function isPolicyChangeLogChangeRoleMessage(reportAction: OnyxInputOrEntry<Repor
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE);
}

function getPolicyChangeLogChangeRoleMessage(reportAction: OnyxInputOrEntry<ReportAction>): string {
function getPolicyChangeLogUpdateEmployee(reportAction: OnyxInputOrEntry<ReportAction>): string {
if (!isPolicyChangeLogChangeRoleMessage(reportAction)) {
return '';
}

const originalMessage = getOriginalMessage(reportAction);
const email = originalMessage?.email ?? '';
const field = originalMessage?.field;
const customFieldType = Object.values(CONST.CUSTOM_FIELD_KEYS).find((value) => value === field);
if (customFieldType) {
const translationKey = field === CONST.CUSTOM_FIELD_KEYS.customField1 ? 'report.actions.type.updatedCustomField1' : 'report.actions.type.updatedCustomField2';
return translateLocal(translationKey, {
email,
newValue: typeof originalMessage?.newValue === 'string' ? originalMessage?.newValue : '',
previousValue: typeof originalMessage?.oldValue === 'string' ? originalMessage?.oldValue : '',
});
}
const newRole = translateLocal('workspace.common.roleName', {role: typeof originalMessage?.newValue === 'string' ? originalMessage?.newValue : ''}).toLowerCase();
const oldRole = translateLocal('workspace.common.roleName', {role: typeof originalMessage?.oldValue === 'string' ? originalMessage?.oldValue : ''}).toLowerCase();
return translateLocal('report.actions.type.updateRole', {email, newRole, currentRole: oldRole});
Expand Down Expand Up @@ -2493,7 +2504,7 @@ export {
getUpdateRoomDescriptionMessage,
didMessageMentionCurrentUser,
getPolicyChangeLogAddEmployeeMessage,
getPolicyChangeLogChangeRoleMessage,
getPolicyChangeLogUpdateEmployee,
getPolicyChangeLogDeleteMemberMessage,
getPolicyChangeLogEmployeeLeftMessage,
getRenamedAction,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ import {
getOneTransactionThreadReportID,
getOriginalMessage,
getPolicyChangeLogAddEmployeeMessage,
getPolicyChangeLogChangeRoleMessage,
getPolicyChangeLogDefaultBillableMessage,
getPolicyChangeLogDefaultTitleEnforcedMessage,
getPolicyChangeLogDeleteMemberMessage,
getPolicyChangeLogEmployeeLeftMessage,
getPolicyChangeLogMaxExpenseAmountMessage,
getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage,
getPolicyChangeLogUpdateEmployee,
getRemovedConnectionMessage,
getRenamedAction,
getReportAction,
Expand Down Expand Up @@ -655,7 +655,7 @@ function getOptionData({
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) {
result.alternateText = getPolicyChangeLogAddEmployeeMessage(lastAction);
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) {
result.alternateText = getPolicyChangeLogChangeRoleMessage(lastAction);
result.alternateText = getPolicyChangeLogUpdateEmployee(lastAction);
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) {
result.alternateText = getPolicyChangeLogDeleteMemberMessage(lastAction);
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) {
Expand Down
Loading