(I'm not sure of the exact conditions under which "Same object reattached" will trigger, but the code does seem to trigger in practice)
When LLViewerJointAttachment::removeObject() is called, it will run "object->setAttachmentItemID(LLUUID::null)" at the very end, which ends up clearing the associated inventory item UUID.
Moving the "object->extractAttachmentItemID()" in addObject to below the "same object reattached" block makes sure that its properly re-set after being cleared.
(Please note that this isn't a duplicate, or viewer-side resolution of SVC-6766. It's the same kind of problem but SVC-6766 is about the region not sending the attachment item UUID while this VWR is about the viewer clearing an attachment's item UUID after it already had it set)