sharing ground for serial connection Across raspberry Pi and Arduino both with different power supply
Generally your power supplies will be isolated from the mains, and generally it's safe to connect the ground of the circuits together.

If you have a concern that they are not isolated, get new power supplies that are, or perform this test:

Connect the two grounds via 100k ohm resistor, then plug them into the mains. Using a multimeter, test the voltage drop across the resistor. If there is a drop larger than a few millivolts, then you will likely be running a ground loop that will cause problems. If there's a very, very small drop then you'll be running a ground loop, but it will probably be acceptable. If there's no drop then you will have no problem.

If you do have a small drop, you can limit the ground loop current with a resistor, and may still be able to have good communications depending on the ground loop signal, but you'd need to do more testing or use an oscilloscope to determine the nature of the ground loop.

Note that you'll want to test for both DC and AC voltage drop.

Also, by plugging into the same phase and ground you'll probably find this test works even if the supplies are not isolated, but if you later connect them to separate phases or grounds you'll have problems. Just keep this in mind if you ever extend your communications line or use these in a different way than currently used.

There are isolated communication methods that will help you if needed, but they will require additional hardware.