Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 51 additions & 38 deletions src/components/ChallengeEditor/ChallengeReviewer-Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,44 +722,57 @@ class ChallengeReviewerField extends Component {
onChange={(e) => this.updateReviewer(index, 'phaseId', e.target.value)}
>
<option value=''>Select Phase</option>
{challenge.phases && challenge.phases
.filter(phase => {
const rawName = phase.name ? phase.name : ''
const phaseName = rawName.toLowerCase()
const norm = phaseName.replace(/[-\s]/g, '')
const isReviewPhase = phaseName.includes('review')
const isSubmissionPhase = phaseName.includes('submission')
const isScreeningPhase = norm === 'screening' || norm === 'checkpointscreening'
const isApprovalPhase = norm === 'approval'
const isPostMortemPhase = norm === 'postmortem'
const isCurrentlySelected = reviewer.phaseId && ((phase.id === reviewer.phaseId) || (phase.phaseId === reviewer.phaseId)) && !isSubmissionPhase

// For AI reviewers, allow review, submission, and other required phases
// For member reviewers, allow review and other required phases
if (this.isAIReviewer(reviewer)) {
return (
isReviewPhase ||
isSubmissionPhase ||
isScreeningPhase ||
isApprovalPhase ||
isPostMortemPhase ||
isCurrentlySelected
)
} else {
return (
isReviewPhase ||
isScreeningPhase ||
isApprovalPhase ||
isPostMortemPhase ||
isCurrentlySelected
)
}
})
.map(phase => (
<option key={phase.id || phase.phaseId} value={phase.phaseId || phase.id}>
{phase.name || `Phase ${phase.phaseId || phase.id}`}
</option>
))}
{challenge.phases && challenge.phases
.filter(phase => {
const rawName = phase.name ? phase.name : ''
const phaseName = rawName.toLowerCase()
const norm = phaseName.replace(/[-\s]/g, '')
const isReviewPhase = phaseName.includes('review')
const isSubmissionPhase = phaseName.includes('submission')
const isScreeningPhase = norm === 'screening' || norm === 'checkpointscreening'
const isApprovalPhase = norm === 'approval'
const isPostMortemPhase = norm === 'postmortem'
const isCurrentlySelected = reviewer.phaseId && ((phase.id === reviewer.phaseId) || (phase.phaseId === reviewer.phaseId)) && !isSubmissionPhase

// Collect phases already assigned to other reviewers (excluding current reviewer)
const assignedPhaseIds = new Set(
(challenge.reviewers || [])
.filter((r, i) => i !== index)
.map(r => r.phaseId)
.filter(id => id !== undefined && id !== null)
)

// Exclude phases already assigned to other reviewers, except the currently selected phase
if (assignedPhaseIds.has(phase.phaseId || phase.id) && !isCurrentlySelected) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The logic here excludes phases already assigned to other reviewers, which is correct. However, consider adding a check to ensure that phase.phaseId and phase.id are not both undefined, as this could lead to unexpected behavior if both are missing.

return false
}

// For AI reviewers, allow review, submission, and other required phases
// For member reviewers, allow review and other required phases
if (this.isAIReviewer(reviewer)) {
return (
isReviewPhase ||
isSubmissionPhase ||
isScreeningPhase ||
isApprovalPhase ||
isPostMortemPhase ||
isCurrentlySelected
)
} else {
return (
isReviewPhase ||
isScreeningPhase ||
isApprovalPhase ||
isPostMortemPhase ||
isCurrentlySelected
)
}
})
.map(phase => (
<option key={phase.id || phase.phaseId} value={phase.phaseId || phase.id}>
{phase.name || `Phase ${phase.phaseId || phase.id}`}
</option>
))}
</select>
)}
{!readOnly && challenge.submitTriggered && validationErrors.phaseId && (
Expand Down