I created an amalgam of your line and mine. The result is absolutely horrible to look at, but it works. I probably should try to squeeze it in a bit, but I'm tempted to leave it as it is and just forget the whole ordeal.
if (lastaction.scene.code in sceneref.analcategories && lastaction.takers.has(self) != lastaction.scene.code in ['cowgirlanal','revcowgirlanal']) || (lastaction.givers.has(self) && (lastaction.scene.code == 'doubledildoass' || lastaction.scene.code == 'cowgirlanal' || lastaction.scene.code == 'revcowgirlanal')):