From eed6c9d24eff8a1ec2759fb2ed9cd88d535b4088 Mon Sep 17 00:00:00 2001
From: Bogdan Cochior <bogdan.cochior@thinslices.com>
Date: Wed, 8 Aug 2018 16:38:40 +0300
Subject: [PATCH] fix(emails): fix EiC reject decision

---
 .../notifications/notifications.js                     | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js
index 2272a85f4..b3f2e877a 100644
--- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js
+++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js
@@ -1,5 +1,5 @@
 const config = require('config')
-const { chain, get } = require('lodash')
+const { chain, get, isEmpty } = require('lodash')
 
 const {
   User,
@@ -58,9 +58,13 @@ module.exports = {
 
       comments = eicComments
     }
+
+    const hasPeerReview = (collection = {}) =>
+      !isEmpty(collection.handlingEditor)
+
     if (
       (isEditorInChief || newRecommendation.recommendationType === 'review') &&
-      collection.status !== 'rejected'
+      hasPeerReview(collection)
     ) {
       // the request came from either the Editor in Chief or a reviewer, so the HE needs to be notified
       sendHandlingEditorEmail({
@@ -93,7 +97,7 @@ module.exports = {
           newRecommendation,
         })
       }
-      if (collection.status !== 'rejected') {
+      if (hasPeerReview(collection)) {
         sendReviewersEmail({
           email,
           baseUrl,
-- 
GitLab