Welcome! Congrats on getting this far!
You want to create a permalink normalization that throws away the slug and create permalinks that include only at the forum id, I think.
All that’s needed to identify the correct topic is t140842-s1, right?
There are some other importers that do that, though I’m not sure which ones. Maybe vBulletin? But if you grep them all for normalization you should find m example.