Open the Messages app
Tap Edit or Filters in the top-left corner
Tap Show Recently Deleted
Select the messages you want to recover
Tap Recover
Tap Recover Messages to confirm
If the messages are not in Recently Deleted, restore from an iCloud backup
Go to Settings
Tap your name
Tap iCloud
Tap iCloud Backup
Check the date of the last backup
Erase the iPhone if needed
During setup, choose Restore from iCloud Backup
Sign in with your Apple ID
Select a backup that contains the deleted messages
If you use Messages in iCloud, check other Apple devices for the deleted messages
Contact your carrier if the messages were SMS and not backed up
