Here is what you should do to prepare a Mac for sale:
What to do before you sell, give away, or trade in your Mac - Apple Support
When getting to the reinstall macOS instructions, things are a bit tricky for an iMac if it uses a hard drive or a Fusion Drive setup. I suggest first enabling Filevault and letting the encryption process finish to the hard drive is encrypted. I'm not sure if this is possible for a Fusion Drive setup. If you don't do this, then someone could recover some files from the hard drive using data recovery software since even a simple erase in Disk Utility only resets the links to the data, but leaves the data on the hard drive. The other option is to write zeroes to the entire hard drive, but Apple removed this from Disk Utility years ago. With just an SSD a simple erase is fine as suggested in the linked article since SSDs work differently than hard drives. I wish Apple actually addressed this issue in their instructions for erasing a Mac's hard drive/Fusion Drive, but their focus is on newer models which utilize SSDs.
FYI, it is dangerous not to properly prepare a computer for sale as you may leave other personal information behind such as your AppleID. Keep in mind most of the third party software installed on your computer is not allowed to be transferred to another user as it may only be licensed to the person who originally made the purchase of the app. Besides, any apps installed from the App Store will be tied to your AppleID which will end up annoying the new user with reminders to update the app which they cannot do because it is tied to your AppleID. Remember, macOS will show the AppleID required to update the app or perhaps even the OS.
You are actually doing a disservice to the new owner as you are giving them a computer with all sorts of unknown customizations made by you (or other users) over the years. A new owner should get the new computer feel by getting to use Setup Assistant when first powering on the Mac in order to configure & customize the computer to their desires just like you did when you first bought the computer.