FIX: improves invitees query perf and prevents loading destroyed user

FIX: improves invitees query perf and prevents loading destroyed user

A destroyed user should destroy the associated invitee, but this an additional security.

diff --git a/app/models/discourse_post_event/invitee.rb b/app/models/discourse_post_event/invitee.rb
index 872de57..137db77 100644
--- a/app/models/discourse_post_event/invitee.rb
+++ b/app/models/discourse_post_event/invitee.rb
@@ -7,6 +7,12 @@ module DiscoursePostEvent
     belongs_to :event, foreign_key: :post_id
     belongs_to :user
 
+    default_scope {
+      joins(:user)
+        .includes(:user)
+        .where('users.id IS NOT NULL')
+    }
+
     scope :with_status, ->(status) {
       where(status: Invitee.statuses[status])
     }
diff --git a/assets/javascripts/discourse/widgets/discourse-post-event-invitee.js.es6 b/assets/javascripts/discourse/widgets/discourse-post-event-invitee.js.es6
index 7acff5e..fc1ffa9 100644
--- a/assets/javascripts/discourse/widgets/discourse-post-event-invitee.js.es6
+++ b/assets/javascripts/discourse/widgets/discourse-post-event-invitee.js.es6
@@ -16,7 +16,6 @@ export default createWidget("discourse-post-event-invitee", {
 
     if (
       this.currentUser &&
-      attrs.invitee.user &&
       this.currentUser.username === attrs.invitee.user.username
     ) {
       classes.push("is-current-user");

GitHub sha: 11ba3980