Editor can't see completed reviews in decision page
Once a reviewer has completed their review of a manuscript, an editor of that manuscript should be able to see that review in the decision page.
But the review is not shown (unless the manuscript already has a decision submitted, or the editor and the reviewer are the same person, or the editor is an admin). This was observed by @markm.
I've managed to diagnose the issue. It happens because in this line whereNotIn('status', ['invited', 'rejected'])
isn't doing what we expect: it returns false if status
is null. I don't know why. Essentially, we're not recognising any of the editor roles.
It can be fixed by replacing with:
// If status is null, whereNotIn('status', ['invited', 'rejected']) returns false.
// I'm not sure why this is, but it means we need to also check for status===null.
.where(builder =>
builder
.whereNull('status')
.orWhereNotIn('status', ['invited', 'rejected']),
)