diff --git a/plugins/chat/lib/extensions/user_notifications_extension.rb b/plugins/chat/lib/extensions/user_notifications_extension.rb index a054b108d85..b64004c3a3b 100644 --- a/plugins/chat/lib/extensions/user_notifications_extension.rb +++ b/plugins/chat/lib/extensions/user_notifications_extension.rb @@ -69,7 +69,10 @@ module Chat::UserNotificationsExtension # Prioritize messages from regular channels over direct messages if channels.any? - channel_notification_text(channels.sort_by(&:last_message_sent_at), dm_users) + channel_notification_text( + channels.sort_by { |channel| [channel.last_message_sent_at, channel.created_at] }, + dm_users, + ) else direct_message_notification_text(dm_users) end