To be sure, even if the data is deleted from the phone, it can usually be recovered with the proper forensics tools, such as a Cellebrite device. Having personal experience with these devices, it is amazing at what they can do. Anyone who knows how mobile phones work, know that they are nothing more than a sleek UI with a database back end. As such, these devices utilize a database to store records in. These records would consist of applications installed, phone logs, and actual copies of text messages, even if they were deleted from the messaging application.
The deleted data persists, just like on standard laptops/desktops until the data is actually overwritten due to space constraints.
Urbs best be blowin' up that SMS, otherwise, these files are still locally recoverable.
But yes, a factory reset will wipe all data.