I just tested this and it appears you must be in a group or raid before the proper bits are set in sourceFlags and destFlags to indicate a raid icon is present. So get someone to group up with you when you need to test.
Also, in the code I posted above, change:
Code:
bit_and(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_MINE)
to:
Code:
bit_and(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_MINE) ~= 0