From 5a13c7ee5f82a3759ebe20d42cf68d000033b16c Mon Sep 17 00:00:00 2001
From: Tania Fecheta <tania.fecheta@thinslices.com>
Date: Tue, 4 Dec 2018 11:11:42 +0200
Subject: [PATCH] fix(manuscriptEicDecision): hide request revision option from
 dropdown after assigning a he

---
 .../manuscriptDetails/ManuscriptEicDecision.js   | 16 ++++++++--------
 .../src/services/Collection.js                   |  7 +++++--
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js
index 7fc2e98e5..07fcac008 100644
--- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js
+++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js
@@ -1,5 +1,5 @@
 import React from 'react'
-import { get, last } from 'lodash'
+import { get, initial } from 'lodash'
 import { compose, withProps } from 'recompose'
 import styled from 'styled-components'
 import { reduxForm } from 'redux-form'
@@ -33,23 +33,23 @@ const eicDecisions = [
     modalTitle: 'Publish Manuscript',
     modalSubtitle: 'A publish decision is final',
   },
-  {
-    value: 'revision',
-    label: 'Request Revision',
-    modalTitle: 'Request Revision',
-  },
   {
     value: 'reject',
     label: 'Reject',
     modalTitle: 'Reject Manuscript',
     modalSubtitle: 'A rejection decision is final',
   },
+  {
+    value: 'revision',
+    label: 'Request Revision',
+    modalTitle: 'Request Revision',
+  },
 ]
 
 const filterOptions = (eicDecisions, status) => {
   if (status === 'submitted') return eicDecisions.slice(2)
-  if (status === 'pendingApproval') return eicDecisions
-  return [last(eicDecisions)]
+  if (status === 'pendingApproval') return initial(eicDecisions)
+  return eicDecisions.slice(2, 3)
 }
 const ManuscriptEicDecision = ({
   status,
diff --git a/packages/component-helper-service/src/services/Collection.js b/packages/component-helper-service/src/services/Collection.js
index ece6c1339..e95d5e866 100644
--- a/packages/component-helper-service/src/services/Collection.js
+++ b/packages/component-helper-service/src/services/Collection.js
@@ -93,7 +93,8 @@ class Collection {
     const allCollectionInvitations = flatMap(
       allCollectionFragments,
       fragment => fragment.invitations,
-    )
+    ).filter(Boolean)
+
     const allNumberedInvitationsForUser = allCollectionInvitations
       .filter(invite => invite.userId === userId)
       .filter(invite => invite.reviewerNumber)
@@ -134,7 +135,9 @@ class Collection {
 
     if (lastEditorRecommendation.recommendation === 'minor') {
       return this.hasAtLeastOneReviewReport(fragments)
-    } else if (lastEditorRecommendation.recommendation === 'major') {
+    } else if (
+      ['major', 'revision'].includes(lastEditorRecommendation.recommendation)
+    ) {
       return fragmentHelper.hasReviewReport()
     }
 
-- 
GitLab