On a 2012 iMac, Bluetooth issues are fairly common as the hardware is aging and macOS updates sometimes don’t play nicely with older Bluetooth chips. Since you’ve already ruled out the batteries, the next step is to figure out whether the problem is with the mouse itself, or with the iMac’s Bluetooth system.
I suggest starting by doing a quick reset of your Mac's Bluetooth module. To do so:
- Hold Shift + Option and click the Bluetooth icon in the menu bar.
- From the menu that appears, choose Reset the Bluetooth module (on some macOS versions, it may be under “Debug”).
- Restart your iMac, then try re-pairing the mouse.
If the mouse still won’t connect, try pairing it with another Mac, iPad, or even a Windows PC that supports Bluetooth. If it works elsewhere, the iMac’s Bluetooth is likely the issue.
Finally, sometimes interference from Wi-Fi (especially on 2.4 GHz) can mess with Bluetooth, so try turning off Wi-Fi temporarily and see if the mouse shows up.