diff --git a/CHANGELOG b/CHANGELOG
index bc9bb7747a4164869274259408b5e40a815a8505..cc2a40ce409fd28f0899addd710b988423ea155c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@ v 8.10.0 (unreleased)
   - Fix MR-auto-close text added to description. !4836
   - Fix issue, preventing users w/o push access to sort tags !5105 (redetection)
   - Add Spring EmojiOne updates.
+  - Fix viewing notification settings when a project is pending deletion
   - Fix pagination when sorting by columns with lots of ties (like priority)
   - Updated project header design
   - Exclude email check from the standard health check
diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb
index d41fc7073c631f97a6b832df8b8b7ee0e63f9ad2..121b598b8f3839f67a9963bc31dfb3ad9b79f597 100644
--- a/app/models/notification_setting.rb
+++ b/app/models/notification_setting.rb
@@ -5,6 +5,7 @@ class NotificationSetting < ActiveRecord::Base
 
   belongs_to :user
   belongs_to :source, polymorphic: true
+  belongs_to :project, foreign_key: 'source_id'
 
   validates :user, presence: true
   validates :level, presence: true
@@ -13,7 +14,13 @@ class NotificationSetting < ActiveRecord::Base
                                     allow_nil: true }
 
   scope :for_groups, -> { where(source_type: 'Namespace') }
-  scope :for_projects, -> { where(source_type: 'Project') }
+
+  # Exclude projects not included by the Project model's default scope (those that are
+  # pending delete).
+  #
+  scope :for_projects, -> do
+    includes(:project).references(:projects).where(source_type: 'Project').where.not(projects: { id: nil })
+  end
 
   EMAIL_EVENTS = [
     :new_note,
diff --git a/spec/factories/notification_settings.rb b/spec/factories/notification_settings.rb
new file mode 100644
index 0000000000000000000000000000000000000000..b5e96d18b8f2aee666e7a68372e24c4c650c3441
--- /dev/null
+++ b/spec/factories/notification_settings.rb
@@ -0,0 +1,8 @@
+FactoryGirl.define do
+  factory :notification_setting do
+    source factory: :empty_project
+    user
+    level 3
+    events []
+  end
+end
diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb
index df336a6effed56ea210f20065305c7830453cf57..d58673413c82b56136c68873886d8bd1dfac44d1 100644
--- a/spec/models/notification_setting_spec.rb
+++ b/spec/models/notification_setting_spec.rb
@@ -38,4 +38,21 @@
       end
     end
   end
+
+  describe '#for_projects' do
+    let(:user) { create(:user) }
+
+    before do
+      1.upto(4) do |i|
+        setting = create(:notification_setting, user: user)
+
+        setting.project.update_attributes(pending_delete: true) if i.even?
+      end
+    end
+
+    it 'excludes projects pending delete' do
+      expect(user.notification_settings.for_projects).to all(have_attributes(project: an_instance_of(Project)))
+      expect(user.notification_settings.for_projects.map(&:project)).to all(have_attributes(pending_delete: false))
+    end
+  end
 end