Mir scheint das ein Bug zu sein.
Ein frisches Moodle 5.1.4 und darin vier Kurskategorien erstellt, hat diese Tabelle:
> select * from mdl_course_categories;
+----+------------+----------+-------------+-------------------+--------+-----------+-------------+---------+------------+--------------+-------+------+-------+
| id | name | idnumber | description | descriptionformat | parent | sortorder | coursecount | visible | visibleold | timemodified | depth | path | theme |
+----+------------+----------+-------------+-------------------+--------+-----------+-------------+---------+------------+--------------+-------+------+-------+
| 1 | Category 1 | NULL | NULL | 1 | 0 | 10000 | 0 | 1 | 1 | 1778310254 | 1 | /1 | NULL |
| 2 | Category Top A | | | 1 | 0 | 20000 | 0 | 1 | 1 | 1778311596 | 1 | /2 | NULL |
| 3 | Cat Top B | | | 1 | 0 | 30000 | 0 | 1 | 1 | 1778311662 | 1 | /3 | NULL |
| 4 | Cat A 1 | | | 1 | 2 | 30000 | 0 | 1 | 1 | 1778311741 | 2 | /2/4 | NULL |
| 5 | Cat A 2 | | | 1 | 2 | 40000 | 0 | 1 | 1 | 1778311807 | 2 | /2/5 | NULL |
Hat keine "root" Kategorie, braucht auch keine!