PR is ready - FIX: topic_creator accepts participant_count in import mode by KrisKotlarek · Pull Request #10632 · discourse/discourse · GitHub
Once merged and deployed you will be able to use it like:
create_posts(pms, total: pms_count, offset: 0) do |pm|
...
p[:topic_opts][:participant_count] = target_usernames.count
...
end
It has to be under [:topic_opts] because create_posts method is evaluating post_creator which triggers topic_creator