-
Notifications
You must be signed in to change notification settings - Fork 3k
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] Hide current user in approver selector when 'prevent self approvals' is enabled #53612
Comments
Triggered auto assignment to @anmurali ( |
|
Triggered auto assignment to Design team member for new feature review - @shawnborton ( |
I think this part: How to handle the users who are already self-approvers is less clear to me and probably requires a non-trivial backend change and maybe better to discuss in #product first. I feel like this is an edge case related to Workflows feature (so cc'ing @tgolen in case he has thoughts on this one as well). |
Edited by proposal-police: This proposal was edited at 2024-12-05 00:52:32 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.Figure out how Prevent Self Approvals should work in NewDot and implement it What is the root cause of that problem?
What changes do you think we should make in order to solve the problem?
Pseudocode const membersEmail = useMemo(() => approvalWorkflow?.members.map((mem) => mem.email), [approvalWorkflow?.members]);
const sections: ApproverSection[] = useMemo(() => {
const approvers: SelectionListApprover[] = [];
if (employeeList) {
const availableApprovers = Object.values(employeeList)
.map((employee): SelectionListApprover | null => {
const isAdmin = employee?.role === CONST.REPORT.ROLE.ADMIN;
const email = employee.email;
if (!email) {
return null;
}
if (policy?.preventSelfApproval && membersEmail?.includes(email)) {
return null;
}
// Do not allow the same email to be added twice
const isEmailAlreadyInApprovers = approversFromWorkflow?.some((approver, index) => approver?.email === email && index !== approverIndex);
if (isEmailAlreadyInApprovers && selectedApproverEmail !== email) {
return null;
}
// Do not allow the default approver to be added as the first approver
if (!isDefault && approverIndex === 0 && defaultApprover === email) {
return null;
}
const policyMemberEmailsToAccountIDs = PolicyUtils.getMemberAccountIDsForWorkspace(employeeList);
const accountID = Number(policyMemberEmailsToAccountIDs[email] ?? '');
const {avatar, displayName = email} = personalDetails?.[accountID] ?? {};
return {
text: displayName,
alternateText: email,
keyForList: email,
isSelected: selectedApproverEmail === email,
login: email,
icons: [{source: avatar ?? FallbackAvatar, type: CONST.ICON_TYPE_AVATAR, name: displayName, id: accountID}],
rightElement: isAdmin ? <Badge text={translate('common.admin')} /> : undefined,
};
})
.filter((approver): approver is SelectionListApprover => !!approver);
approvers.push(...availableApprovers);
// eslint-disable-next-line react-compiler/react-compiler
setAllApprovers(approvers);
}
const filteredApprovers =
debouncedSearchTerm !== ''
? approvers.filter((option) => {
const searchValue = OptionsListUtils.getSearchValueForPhoneOrEmail(debouncedSearchTerm);
const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue);
return isPartOfSearchTerm;
})
: approvers;
const data = OptionsListUtils.sortAlphabetically(filteredApprovers, 'text');
return [
{
title: undefined,
data,
shouldShow: true,
},
];
}, [
approversFromWorkflow,
isDefault,
approverIndex,
debouncedSearchTerm,
defaultApprover,
personalDetails,
employeeList,
selectedApproverEmail,
translate,
policy?.preventSelfApproval,
membersEmail,
]); What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
What alternative solutions did you explore? (Optional) |
@Krishna2323 looks good, but not ready for proposals just yet. |
Hid the proposal 😅. Will add it back when we're ready for proposals. |
I would think for this case, we:
|
Ah, so, maybe it is a bit easier to have them set back to whatever the default approver here is? Or are we wanting to update each custom workflow to the workspace owner with some kind of note? Either way, I think we may need a backend change since all the affected reports would need to have their
The user updating the prevent self approval setting would be on the "Rules" page. I think it would be easier to update them without having any kind of highlighting, but I might be missing why that's important. |
Yeah great call! Let's set them back to the default approver. In that case, also no need for highlighting. |
@marcaaron do you think we're ready to open up to proposals following our discussion last week? |
@JmillsExpensify, do we want to show the modal or we just want to exclude the members from the approvers list? |
Yeah. Ok, I think for clarity I am going to split this into two separate issues and we will make this one External and only focus on the exclusion of the user from the person selector page.
Let's chat about this in the next issue. |
Job added to Upwork: https://www.upwork.com/jobs/~021866263734682899164 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @brunovjk ( |
With that I think we can go with @Krishna2323's proposal 🎀👀🎀 C+ reviewed |
Current assignee @marcaaron is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new. |
📣 @brunovjk 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @Krishna2323 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
@brunovjk PR ready for review ^ |
I think the automation failed to update the status. The PR was deployed to production on December 18th. |
cc @JmillsExpensify coming from our DM
While we have the ability to set "Prevent self approval" on a workspace. There are some ways in which this feature works unexpectedly in NewDot. Specifically, the following scenarios seem possible and should not be:
Incorrect workflow setup restrictions
Problem
In NewDot, we just let it happen:
Solution:
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @brunovjkThe text was updated successfully, but these errors were encountered: