The solution is to upgrade to 2.3.4 (just released). Upgrading from 2.3.1 to 2.3.4 is an easy and low risk operation (or course this not a reason not to backup everything before upgrading, because even simple operations can go wrong !). An even better solution if you can would be to upgrade to 2.4.1 but this is a bigger change.
Backporting the changes I did to 2.3.1 would be difficult and require understanding of how import code works in Moodle.