Connect light with 3 wires to box with 6 wires
Color distinguish wires in cables, it does not connote wire function. If you want the latter, you can mark wires with tape.   There's one exception, neutral wires must be white but white wires don't have to be neutral.  

So the all-white gaggle must be neutral, and since your lamp actually does need neutral, your lamp white should go there.  The pigtail probably fell out of that.

The black-white gaggle cannot be neutral, since black cannot be neutral.  Therefore neither can the white wire.  This is surely an always-hot wire, going onward to the switch in a switch loop. The third most recent Code change requires in switch loops, white must be the always-hot, so it is obviously hot and is not confused with neutral*.

Grounds are simple, all grounds connect together.  Green, yellow/green and bare a reserved for grounds and vice versa. 

That leaves the two blacks plus the black on the lamp.  These are all accounted for: one is switched-hot from the switch.  One is onward power to the other lamp.  The third is obviously the lamp.  All these go together. 



*The second most recent Code change requires white wires so used actually be re-colored with tape. The most recent Code change requires actual neutral to be wired to switch loops, so white is reserved for that.)