Starting iOS 16, deleted messages and conversation can be recovered on iPhone.
In Messages, tap Edit in the upper-left corner.
This button might say "Filters", if you have Filter Unknown Senders turned on.
Then tap Show Recently Deleted,
select the conversation you want to restore,
and tap Recover in the bottom-right corner.
Tap Recover Messages
Then tap Done in the upper-right corner when you're finished.
This will recover all messages and media, including photos and videos for the conversation.
You can recover deleted messages for up to 30 days.