I’m looking to create a wrapper for this bit of code

I’m looking to create a wrapper for this bit of code, as I’ve found myself repeating myself in a couple other callbacks, here and here

export const departureCallback = async ({ ack, body, client, logger }) => {
    await ack()

    const { user_id } = body

    const records = await fetchAirtable('Protected Slash Commands')

    const {
        profile: { email: userEmail },
    } = await client.users.profile
        .get({ user: user_id })
        .catch((e) => console.log(e))

    const authorizedUser = records.find(
        (record) => record.email === userEmail && record[departure]
    )

    if (!authorizedUser) {
        await client.chat.postMessage({
            channel: user_id,
            ...noPermission,
        })
        return
    }
}