Open IuliiaHerets opened 2 days 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.
@anmurali FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
Approver field in category editor shows user email instead of user name
https://github.com/Expensify/App/blob/d860f2d0ffb31c478d9400bab1df18022a14a0b5/src/libs/CategoryUtils.ts#L47-L49 We display the approver field here which is the approver email
Update getCategoryApprover
to get the approver display name using the email, and return the display name
function getCategoryApprover(approvalRules: ApprovalRule[], categoryName: string) {
const approverEmail = approvalRules?.find((rule) => rule.applyWhen.some((when) => when.value === categoryName))?.approver;
if(!approverEmail){
return;
}
const approver = PersonalDetailsUtils.getPersonalDetailByEmail(approverEmail);
return approver?.displayName ?? approverEmail;
}
Approver field in category editor shows user email instead of user name
We show the approver field here which is email of approver
We should avoid updating the getCategoryApprover function, as changes could impact other places
We should retrieve the display name from PersonalDetails and show that instead of displaying the email address directly.
const approverText = useMemo(() => {
const categoryApprover = CategoryUtils.getCategoryApprover(policy?.rules?.approvalRules ?? [], categoryName);
const approver = PersonalDetailsUtils.getPersonalDetailByEmail(categoryApprover ?? '');
return approver.displayName ?? categoryApprover ?? '';
}, [categoryName, policy?.rules?.approvalRules]);
Approver field in category editor shows user email instead of user name.
categoryApprover
here is the email of approver
We should get the personal details of the approver based on the email then use getDisplayNameOrDefault
function to get the display name of the approver
const approverText = useMemo(() => {
const categoryApprover = CategoryUtils.getCategoryApprover(policy?.rules?.approvalRules ?? [], categoryName);
if (!categoryApprover) {
return '';
}
const personalDetails = getPersonalDetailByEmail(categoryApprover);
return getDisplayNameOrDefault(personalDetails) ?? '';
}, [categoryName, policy?.rules?.approvalRules]);
getDisplayNameOrDefault
function will cover all cases of the user like remove SMS domain of phone number user, ....What alternative solutions did you explore? (Optional)
We can create a new util like
getCategoryApproverDisplayName
and usegetCategoryApprover
function and the logic above to return the display name of the approver
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.35-0 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): applausetester+kh010901@applause.expensifail.com Issue reported by: Applause Internal Team
Action Performed:
Precondition:
Expected Result:
Approver field in category editor will show user name.
Actual Result:
Approver field in category editor shows user email instead of user name.
Workaround:
Unknown
Platforms:
Screenshots/Videos
https://github.com/user-attachments/assets/8b3b3166-0e59-42e9-a2e9-427353d7b9f6
View all open jobs on GitHub