diff --git a/web/components/contract/contract-tabs.tsx b/web/components/contract/contract-tabs.tsx
index c28cb5cb..9639a57a 100644
--- a/web/components/contract/contract-tabs.tsx
+++ b/web/components/contract/contract-tabs.tsx
@@ -93,24 +93,56 @@ const CommentsTabContent = memo(function CommentsTabContent(props: {
const tipsOrBountiesAwarded =
Object.keys(tips).length > 0 || comments.some((c) => c.bountiesAwarded)
- const sortedComments = sortBy(comments, (c) =>
- sort === 'Newest'
- ? c.createdTime
- : // Is this too magic? If there are tips/bounties, 'Best' shows your own comments made within the last 10 minutes first, then sorts by score
- tipsOrBountiesAwarded &&
- c.createdTime > Date.now() - 10 * MINUTE_MS &&
- c.userId === me?.id
- ? -Infinity
- : -((c.bountiesAwarded ?? 0) + sum(Object.values(tips[c.id] ?? [])))
- )
+ // replied to answers/comments are NOT newest, otherwise newest first
+ const shouldBeNewestFirst = (c: ContractComment) =>
+ c.replyToCommentId == undefined &&
+ (contract.outcomeType === 'FREE_RESPONSE'
+ ? c.betId === undefined && c.answerOutcome == undefined
+ : true)
+
+ // TODO: links to comments are broken because tips load after render and
+ // comments will reorganize themselves if there are tips/bounties awarded
+ const sortedComments = sortBy(comments, [
+ sort === 'Best'
+ ? (c) =>
+ // Is this too magic? If there are tips/bounties, 'Best' shows your own comments made within the last 10 minutes first, then sorts by score
+ tipsOrBountiesAwarded &&
+ c.createdTime > Date.now() - 10 * MINUTE_MS &&
+ c.userId === me?.id &&
+ shouldBeNewestFirst(c)
+ ? -Infinity
+ : -((c.bountiesAwarded ?? 0) + sum(Object.values(tips[c.id] ?? [])))
+ : (c) => c,
+ (c) => (!shouldBeNewestFirst(c) ? c.createdTime : -c.createdTime),
+ ])
const commentsByParent = groupBy(
sortedComments,
(c) => c.replyToCommentId ?? '_'
)
const topLevelComments = commentsByParent['_'] ?? []
- // Top level comments are reverse-chronological, while replies are chronological
- if (sort === 'Newest') topLevelComments.reverse()
+
+ const sortRow = comments.length > 0 && (
+