diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index b3911b9d43..73ebae0e1c 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -1158,7 +1158,8 @@ UserData *Session::userByPhone(const QString &phone) const { PeerData *Session::peerByUsername(const QString &username) const { const auto uname = username.trimmed(); for (const auto &[peerId, peer] : _peers) { - if (!peer->userName().compare(uname, Qt::CaseInsensitive)) { + if (peer->isLoaded() + && !peer->userName().compare(uname, Qt::CaseInsensitive)) { return peer.get(); } }