Google's Pixel 3A for sure. Faster performance and better camera than the Galaxy A51. Galaxy A51 however does have a better screen, and "more" cameras (ultra-wide, macro, etc.). At $400, I personally think the Pixel 3A is the best choice. Motorola does have some good choices though if you want to spend less. The Moto G Fast ($199) and Moto G Power (currently only $229) both have great performance, great battery life, clean Android 10 build (with one promised update to Android 11 in the fall) and actually have decent camera quality now. The Moto G Fast and G Power are both unlocked for all carriers in the US.
However, if you can hold off a little bit, OnePlus will be showing off the OnePlus Nord next week on Tuesday. Rumors say it may or may not come to the USA, and we don't know the price for sure. I have seen it, again just rumored, as anywhere from $349 to $499. Since you are coming from a OnePlus phone, I thought you might be interested in knowing that.