@@ -127,18 +127,37 @@ export const sendSlackTaskAssignedNotification = async (
127127
128128/**
129129 * Send a notification to users that a reimbursement request is created on Slack
130- * @param requestId the id if the reimbursement request
130+ * @param requestId the id of the reimbursement request
131131 * @param submitterId the id of the user who created the reimbursement request
132+ * @param organizationId the organization id of the current user
132133 */
133134export const sendReimbursementRequestCreatedNotificationAndCreateMessageInfo = async (
134135 requestId : string ,
135- requestIdentifier : number ,
136136 submitterId : string ,
137137 organizationId : string
138138) : Promise < void > => {
139139 if ( process . env . NODE_ENV !== 'production' && ! DEV_TESTING_OVERRIDE ) return ; // don't send msgs unless in prod
140140
141- const msg = `${ await getUserSlackMentionOrName ( submitterId ) } created a reimbursement request (ID#: ${ requestIdentifier } ) 💲` ;
141+ const reimbursementRequest = await prisma . reimbursement_Request . findUnique ( {
142+ where : { reimbursementRequestId : requestId } ,
143+ select : {
144+ identifier : true ,
145+ totalCost : true ,
146+ description : true ,
147+ vendor : {
148+ select : {
149+ name : true
150+ }
151+ }
152+ }
153+ } ) ;
154+
155+ if ( ! reimbursementRequest ) throw new HttpException ( 500 , 'Reimbursement request does not exist!' ) ;
156+
157+ const { identifier, totalCost, description, vendor } = reimbursementRequest ;
158+ const formattedCost = `$${ ( totalCost / 100 ) . toFixed ( 2 ) } ` ; // convert from cents to dollars and cents
159+
160+ const msg = `${ await getUserSlackMentionOrName ( submitterId ) } created a reimbursement request for ${ formattedCost } at ${ vendor . name } (ID#: ${ identifier } ) 💲` ;
142161 const link = `https://finishlinebyner.com/finance/reimbursement-requests/${ requestId } ` ;
143162 const linkButtonText = 'View Reimbursement Request' ;
144163
@@ -151,13 +170,23 @@ export const sendReimbursementRequestCreatedNotificationAndCreateMessageInfo = a
151170 const messageInfo = await sendMessage ( financeTeam . slackId , msg , link , linkButtonText ) ;
152171 if ( ! messageInfo ) return ;
153172
154- await prisma . message_Info . create ( {
173+ const createdMessageInfo = await prisma . message_Info . create ( {
155174 data : {
156175 reimbursementRequestId : requestId ,
157176 channelId : messageInfo . channelId ,
158177 timestamp : messageInfo . ts
159178 }
160179 } ) ;
180+
181+ const { messageInfoId, channelId, timestamp } = createdMessageInfo ;
182+
183+ // send reimbursement request description in slack thread
184+ if ( description ) {
185+ await sendThreadResponse (
186+ [ { messageInfoId, channelId, timestamp, changeRequestId : null } ] ,
187+ `Description: ${ description } `
188+ ) ;
189+ }
161190} ;
162191
163192/**
0 commit comments