select
chats.*,
others.first_name,
others.last_name
from chats
inner join chat_participants on chat_participants.chart_id = chats.id and chat_participants.user_id = 1 and chat_participants.is_deleted = false
left join chat_participants as other_participants on other_participants.chart_id = chats.id and other_participants.user_id != 1 and other_participants.is_deleted = false
left join users as others on others.id = other_participants.user_id;