Import_scripts validator does not account for max_category_nesting > 2

Importing my MyBB instance into discourse instance with SiteSetting.max_category_nesting = 3 fails with this error:

creating users
       66 / 330 ( 20.0%)  [633 items/min]  /root/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7/lib/active_record/validations.rb:80:in `raise_validation_error': Validation failed: You can't nest a subcategory under another (ActiveRecord::RecordInvalid)

I’m guessing the validator wasn’t written with this somewhat recent change in mind.