This article explains how to sync your messages and how to fix it if syncing in the Messages app is not working.
How to Sync Messages from iPhone to Mac in 2024
Apple assumes that you want all of your iMessages available on both your iPhone and your Mac, so it makes it easy to sync messages between devices. You may have enabled automatic syncing when you set up both devices. To ensure that all of your text messages sync between your iPhone and Mac, follow these steps:
On your iPhone, go to Settings > Messages > Send & Receive. You'll need the information on this screen for your Mac settings.
Open the Messages app on your Mac.