Correct way to ground components for solar panel measurement
The first is the correct one.

Take a look at its functional block diagram for a typical hall-effect switch, such as A3144 here.



Or typical linear hall-effect sensor, such as OH49E here.



Hall-effect sensor/switch needs the same ground reference for its internal circuitry to be able to work.
The ADC from the voltage divider input needs the same ground reference as well.

If you're not working on very precise, accurate, low noise requirement, then it's good enough.
Else you might want to consider to separate the digital and analog ground, read more here