Is it safe to have common grounds in this circuit?
There may be more than one "ground" here.  The ground that goes with the 110 VAC line voltage may be isolated from the DC voltage produced by the power supply internal to the left device.  Therefore GND at its bottom and GND at its right may not be connected.  However, that doesn't matter.

Not only is it OK to connect GND (the green wire) between the device and the comparator, it is essential.  Voltages are relative between two conductors.  The SIG line by itself doesn't contain any information without something as a reference.  GND is the obvious reference.

Presumably the comparator device has a single ground, so its red GND and green GND are connected internally.