It doesn't need to be totally flat, but a steep incline may cause problems taking off or landing. You may need to make a hand launch and catch, the latter probably requiring the sensors to be turned off.
That's the ideal situation assuming the sensors are able to detect the unsafe landing location. Since the sensors are not foolproof, it would be best to take off from a location where the ground is flat (if possible).
I did some testing the other day of rth in my area. I launched from a pad on flat ground. Flew out hit rth and it wanted to land on the hill instead. So I took back over and blamo. Landed like a pro lol