diff --git a/src/RoomInfoListItem.cpp b/src/RoomInfoListItem.cpp
index 8bebb0f50c46cc669679a09a62c7b058013f9703..77de8d5a56ea48b537b2ccc9e224c9ce0b261846 100644
--- a/src/RoomInfoListItem.cpp
+++ b/src/RoomInfoListItem.cpp
@@ -107,18 +107,6 @@ RoomInfoListItem::RoomInfoListItem(QString room_id, RoomInfo info, QWidget *pare
   , unreadHighlightedMsgCount_(0)
 {
         init(parent);
-
-        QString emptyEventId;
-
-        // HACK
-        // We use fake message info with an old date to pin
-        // the invite events to the top.
-        //
-        // State events in invited rooms don't contain timestamp info,
-        // so we can't use them for sorting.
-        if (roomType_ == RoomType::Invited)
-                lastMsgInfo_ = {
-                  emptyEventId, "-", "-", "-", QDateTime::currentDateTime().addYears(10)};
 }
 
 void
diff --git a/src/RoomList.cpp b/src/RoomList.cpp
index c5e056214335d76224a8b95ef45d401f9df44a02..dfd4eff86de879e95821e029759690c6b269f78e 100644
--- a/src/RoomList.cpp
+++ b/src/RoomList.cpp
@@ -15,6 +15,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <limits>
+
 #include <QApplication>
 #include <QBuffer>
 #include <QObject>
@@ -191,6 +193,9 @@ RoomList::sync(const std::map<QString, RoomInfo> &info)
 {
         for (const auto &room : info)
                 updateRoom(room.first, room.second);
+
+        if (!info.empty())
+                sortRoomsByLastMessage();
 }
 
 void
@@ -270,7 +275,9 @@ RoomList::sortRoomsByLastMessage()
                         continue;
 
                 // Not a room message.
-                if (room->lastMessageInfo().userid.isEmpty())
+                if (room->isInvite())
+                        times.emplace(std::numeric_limits<uint64_t>::max(), room);
+                else if (room->lastMessageInfo().userid.isEmpty())
                         times.emplace(0, room);
                 else
                         times.emplace(room->lastMessageInfo().datetime.toMSecsSinceEpoch(), room);