Try changing the if statement to this..
Lua Code:
if (bit.band(flag,0x0000FC00) == 0x00000800 and bit.band(flag,0x000000F0) == 0x00000020) or bit.band(flag,0x0000FC00) == 0x00001000 or bit.band(flag,0x0000FC00) == 0x00002000 or (guid and guid:len() >= 5 and tonumber(guid:sub(5,5), 16) % 8 == 4) then
A unit can not have a name, but it should never be missing a GUID. If the GUID field is missing, there's no way to track the unit. In other words even if there were a unit without a GUID, it wouldn't be possible to identify who it belonged to.
I know for a
fact stampeded pets all have GUIDs and even guardians summoned by trinkets such as voodoo gnomes do as well.