Skip to content

Commit 63448ba

Browse files
committed
Don't send RR slack notif if approver is submitter, user dropdown fix
1 parent 7849791 commit 63448ba

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

src/backend/src/utils/slack.utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,14 @@ export const sendReimbursementRequestLeadershipApprovedNotification = async (
213213
threads: SlackMessageThread[],
214214
approverId: string,
215215
recipientId: string
216-
) =>
216+
) => {
217+
// Only notify parties if the recipient is different from the approver
218+
if (approverId === recipientId) return;
217219
await sendThreadResponse(
218220
threads,
219221
`${await getUserSlackMentionOrName(approverId)} has approved this reimbursement request. ${await getUserSlackMentionOrName(recipientId)} you may now purchase the items, add the receipts, and mark the reimbursement request as pending finance.`
220222
);
223+
};
221224

222225
export const sendReimbursementRequestChangesRequestedNotification = async (threads: SlackMessageThread[], userId: string) =>
223226
await sendThreadResponse(

src/frontend/src/pages/FinancePage/ReimbursementRequestDetailPage/AssignFinanceMemberModal.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Autocomplete, FormControl, FormLabel, TextField } from '@mui/material';
22
import { useAssignMemberToRR } from '../../../hooks/finance.hooks';
33
import { useToast } from '../../../hooks/toasts.hooks';
4-
import { ReimbursementRequest } from 'shared';
4+
import { ReimbursementRequest, User } from 'shared';
55
import { useEffect, useState } from 'react';
66
import ErrorPage from '../../ErrorPage';
77
import LoadingIndicator from '../../../components/LoadingIndicator';
88
import { useAllUsers } from '../../../hooks/users.hooks';
99
import NERModal from '../../../components/NERModal';
10+
import { fullNamePipe } from '../../../utils/pipes';
1011

1112
interface AssignFinanceMemberModalProps {
1213
modalShow: boolean;
@@ -36,6 +37,7 @@ const AssignFinanceMemberModal = ({ modalShow, onHide, reimbursementRequest }: A
3637
throw new Error('Must select a user to assign');
3738
}
3839
await assignMember({ assigneeId: userId });
40+
toast.success('Finance member assigned successfully');
3941
} catch (error: unknown) {
4042
if (error instanceof Error) {
4143
toast.error(error.message);
@@ -44,6 +46,20 @@ const AssignFinanceMemberModal = ({ modalShow, onHide, reimbursementRequest }: A
4446
onHide();
4547
};
4648

49+
const usersSearchOnChange = (
50+
_event: React.SyntheticEvent<Element, Event>,
51+
value: { label: string; id: string } | null
52+
) => {
53+
if (value) {
54+
setUserId(value.id);
55+
} else {
56+
setUserId(undefined);
57+
}
58+
};
59+
const userToAutocompleteOptionWithRole = (user: User): { label: string; id: string } => {
60+
return { label: `${fullNamePipe(user)} (${user.email}) - ${user.role}`, id: user.userId.toString() };
61+
};
62+
4763
return (
4864
<NERModal
4965
open={modalShow}
@@ -56,12 +72,8 @@ const AssignFinanceMemberModal = ({ modalShow, onHide, reimbursementRequest }: A
5672
<FormControl fullWidth>
5773
<FormLabel>Assignee</FormLabel>
5874
<Autocomplete
59-
options={users}
60-
getOptionLabel={(option) => `${option.firstName} ${option.lastName}`}
61-
value={users.find((user) => user.userId === userId)}
62-
onChange={(_event, value) => {
63-
setUserId(value?.userId);
64-
}}
75+
options={users.map(userToAutocompleteOptionWithRole)}
76+
onChange={usersSearchOnChange}
6577
renderInput={(params) => <TextField {...params} variant="outlined" placeholder="Select User" error={false} />}
6678
/>
6779
</FormControl>

0 commit comments

Comments
 (0)