Skip to content

Conversation

@jmgasper
Copy link
Collaborator

Related JIRA Ticket:

https://topcoder.atlassian.net/browse/PM-2606

What's in this PR?

Fixes for mixed role processing and checkpoint screener specifics.

@jmgasper jmgasper requested a review from kkartunov as a code owner October 28, 2025 11:15
@jmgasper jmgasper merged commit a67129b into dev Oct 28, 2025
4 of 6 checks passed
.toUpperCase()
: ''
const hasValidScore = typeof review.finalScore === 'number'
&& Number.isFinite(review.finalScore)

Choose a reason for hiding this comment

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

[💡 readability]
The use of typeof review.finalScore === 'number' && Number.isFinite(review.finalScore) is a good check for a valid score. However, consider using Number.isNaN(review.finalScore) to explicitly check for NaN values, which can sometimes be more readable and convey the intent more clearly.


const reviewInfo = reviewDetail.reviewInfo
const reviewId = reviewInfo?.id || reviewDetail.reviewId
const reviewId = reviewInfo?.id ?? reviewDetail.reviewId

Choose a reason for hiding this comment

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

[⚠️ correctness]
The change from || to ?? is appropriate here as it ensures that reviewDetail.reviewId is only used when reviewInfo?.id is null or undefined, which is the intended behavior for nullish coalescing.

const reviewId = reviewInfo?.id ?? reviewDetail.reviewId

if (!reviewInfo || !reviewId) {
if (!reviewId) {

Choose a reason for hiding this comment

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

[❗❗ correctness]
The removal of the !reviewInfo check may lead to potential issues if reviewInfo is null or undefined. Ensure that reviewInfo is always defined when this function is called, or consider adding a check to prevent possible runtime errors.

})
.catch(e => {
handleError(e)
setResourceRoleMapping(current => ensureResourceRoleMapping(current))

Choose a reason for hiding this comment

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

[⚠️ correctness]
In the catch block, setResourceRoleMapping(current => ensureResourceRoleMapping(current)) is called. If current is undefined, ensureResourceRoleMapping will handle it, but it's worth considering if this behavior is intentional and if it might lead to unexpected results. Ensure that undefined is an acceptable input here.

* Review result info
*/
export interface ReviewResult {
id?: string

Choose a reason for hiding this comment

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

[⚠️ correctness]
The id field is added as optional in the ReviewResult interface. Ensure that the rest of the codebase handles cases where id might be undefined, especially if id is used as a unique identifier or key in collections.

appeals: [],
createdAt,
createdAtString,
id: data.id,

Choose a reason for hiding this comment

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

[⚠️ correctness]
The id field is directly assigned from data.id. Ensure that data.id is always defined and valid, or handle cases where it might be undefined to prevent potential issues in the UI or data processing.

? isPassingReviewRaw
: undefined
const reviewEntries = Array.isArray(data.review) ? data.review : []
const reviewInfos = reviewEntries.map(convertBackendReviewToReviewInfo)

Choose a reason for hiding this comment

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

[⚠️ correctness]
The reviewEntries variable is already checked to be an array, so the map operation on line 113 is safe. However, consider adding a check to ensure that convertBackendReviewToReviewInfo and convertBackendReviewToReviewResult handle any potential edge cases within their implementations, such as null or undefined values within reviewEntries.


if (reviewInfo.submitterHandleColor) {
group.submitterHandleColor = reviewInfo.submitterHandleColor
const reviewDate = reviewInfo?.reviewDate

Choose a reason for hiding this comment

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

[⚠️ correctness]
The logic for determining reviewDate is complex and may lead to unexpected results if reviewResult.reviewDate is not a valid Date object. Consider simplifying this logic or adding validation to ensure reviewResult.reviewDate is a Date object before using it.

const detailReviewId = detail.reviewInfo?.id ?? detail.reviewId
return detailReviewId === reviewId
})
const existingDetail = group.reviews.find(detail => {

Choose a reason for hiding this comment

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

[⚠️ correctness]
The logic for finding existingDetail is complex and may lead to unexpected results if detailReviewId and reviewId are both undefined. Consider simplifying this logic or adding validation to ensure these IDs are defined before comparison.

existingDetail.finishedAppeals = appealInfo.finishAppeals
const reviewerHandleForDetail = resolvedReviewerHandle ?? fallbackMappedHandle
const resolvedStatus = normalizedReviewInfo?.status
?? ((finalScore !== undefined && reviewDate)

Choose a reason for hiding this comment

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

[⚠️ correctness]
The resolvedStatus logic assumes that a review is 'COMPLETED' if finalScore and reviewDate are defined. This might not cover all cases where a review is considered complete. Consider adding more explicit status checks or comments to clarify this assumption.

}

if (!isPastReviewDetail) {
if (!nextTab && !isPastReviewDetail) {

Choose a reason for hiding this comment

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

[⚠️ correctness]
The condition if (!nextTab && !isPastReviewDetail) is used to determine whether to set nextTab based on open challenge phases. Ensure that visibleChallengePhases is correctly filtered and sorted to avoid unexpected behavior when determining the open tab.

nextTab = tabItems[0]?.value
}

if (nextTab && nextTab !== selectedTab) {

Choose a reason for hiding this comment

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

[💡 correctness]
The check if (nextTab && nextTab !== selectedTab) ensures that the tab is only updated if it differs from the current selection. This is good for preventing unnecessary updates, but consider if there are edge cases where selectedTab might not be correctly initialized, leading to missed updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants