It’s safer and more predictable to do your Thai visa application in South Africa (Pretoria) rather than flying to Hanoi now.
Given your recent travel pattern and the immigration questioning you received, another quick exit and reentry could raise more red flags at Thai immigration.