As Ellie’s graphic shows, the re-entry permit is valid until the expiration date of your current stamp. It is not an extension of any kind. Whether you get “more than 3 weeks” depends on your current stamp.
Are your flights on the same ticket? In normal circumstances, you would then go through passport control for your FIRST flight, and be a CIQ (transit) passenger in BKK.