Fix old user notes not loading

What does this MR do and why?

Makes old user notes load again.

In some older issues, comments are not loading at all. Right now, all comments that contain a system note at the beginning are not loaded leading to empty issues

Example: gitlab-foss#3299 (closed)

🛠️ with ❤️ at Siemens

Closes #581732 (closed)

References

Screenshots or screen recordings

image

image

How to set up and validate locally

On gitlab.com

  1. Visit gitlab-foss#3299 (closed) and notice that the comments are not loading
  2. Open the developer console, network tab
  3. Reload the page and search for "graphql" in the network tab
  4. Find the payload by operationName: workItemNotesByIid and go to the Response tab
  5. Notice how comments are actually loaded, but the first note is a system note

In the GDK

Let's create a broken issue

  1. Open the rails console
  2. Paste this in
project = Project.find_by_full_path('flightjs/Flight')
issue = project.issues.create!(
  title: 'Test issue with system note thread',
  description: 'Testing'
)
user = User.first
system_note = Note.create!(
  noteable: issue,
  project: project,
  author: user,
  note: 'changed milestone to Test',
  system: true,
  system_note_metadata: SystemNoteMetadata.new(action: 'milestone')
)
discussion_id = issue.notes.last.discussion_id
Note.create!(
  noteable: issue,
  project: project,
  author: User.first,
  note: 'First user comment in system note thread',
  discussion_id: discussion_id
)
Note.create!(
  noteable: issue,
  project: project,
  author: User.first,
  note: 'Second user comment in system note thread',
  discussion_id: discussion_id
)

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Please help me to add tests here. Not sure how to do that

Edited by Max Wittig

Merge request reports

Loading