@@ -26,7 +26,8 @@ import {
2626 selectCurrentMembers ,
2727 selectHasUpdateReviewAssignmentsPermission ,
2828 selectReviewPeriod ,
29- selectReviewPeriods
29+ selectReviewPeriods ,
30+ selectSupervisors ,
3031} from '../../../context/selectors' ;
3132import { titleCase } from '../../../helpers/strings.js' ;
3233
@@ -90,14 +91,26 @@ const ReviewPeriodCard = ({ mode, onSelect, periodId, selfReviews }) => {
9091 if ( res . error ) return ;
9192
9293 const assignments = res . payload . data ;
94+
95+ const supervisors = selectSupervisors ( state ) ;
96+ for ( const assignment of assignments ) {
97+ // If the reviewer is not a supervisor, locally modify the assignment
98+ // so that this will count as one to be approved by the reviewer's
99+ // supervisor.
100+ const id = assignment . reviewerId ;
101+ if ( ! supervisors . some ( s => s . id === id ) ) {
102+ const member = currentMembers . find ( m => m . id === id ) ;
103+ if ( member ) {
104+ assignment . reviewerId = member . supervisorid ;
105+ }
106+ }
107+ }
108+
93109 const approvedCount = assignments . filter ( a => a . approved ) . length ;
94110 setOverallApprovalPercentage ( ( 100 * approvedCount ) / assignments . length ) ;
95111
96112 // Get a list of all the reviewers in this period.
97- const reviewerIds = new Set ( ) ;
98- for ( const assignment of assignments ) {
99- reviewerIds . add ( assignment . reviewerId ) ;
100- }
113+ const reviewerIds = new Set ( assignments . map ( a => a . reviewerId ) ) ;
101114 const reviewers = [ ...reviewerIds ] . map ( id =>
102115 currentMembers . find ( m => m . id === id )
103116 ) ;
0 commit comments