How can I know on which device I get Apple verification code? I have one Mac, two iPhones, and 2 iPads. There are 4 Apple accounts used on those devices, with some of them switching to each other. It is also common that on some device the system and App Store account used are different.
Now, it is very common that whenever I log in to my Apple account on a device, the popup shows up, forcing me to type in 6-digits code that is sent to another device(s). But I'm not sure which device I got the code on.
It seems that all of them happen. The code is sent to:

The device that logged in to either the same system or the App Store account
The device that logged in to the same system account
The device that logged in to the same App Store account
The device that does not log in to the same account (neither system nor App Store)
No device gets the code but the popup still forces me to type in code

Also there is even a case where the device got the code when I tried to login from one device but doesn't from another...
So on what rule is the verification code sent?
In all of these accounts I already lost my phone number, so it is not possible to get the code via SMS.
Apple ID verification codes will appear on all devices logged into the same primary iCloud account.
On an iOS device, go to Settings → your name and tap on a device in the list. If the device says

This device is trusted and can receive Apple ID verification codes.

then you can expect this device to show the code when you need to log in on another device. All devices which show this message will receive the Apple ID verification code.
Devices only logged into the same account for iTunes &amp; App Stores, iMessage and/or FaceTime will not receive Apple ID verification codes.