Segment Visibility Code Not Functioning for me

Hi,
I have an issue where indeed I can set the entire segmentation to not be visible via vtkMRMLSegmentationNode by doing:
display = segmentation.GetDisplayNode()
display.SetVisibility(0)

However, whenever I attempt to set a particular segment to not be visible by doing:
display.SetSegmentVisibility(segment_id,0)
The segment is still visible to me. When I attempt accessing the node through Python I indeed see that the Visibility for the segment has been set to false, however why is the segment still appearing on my views?
Am I missing some code here?
Thanks!

Thanks for the detailed explanation!

What Slicer version do you use?
I tried a recent nightly, and the same code works for me. Is it possible that you try to use the name of the segment and not its ID? If you rename a segment then its ID will still be the original ‘Segment_1’ for example, and GetSegmentVisibility will return a simple False on invalid ID as well (but an error appears in the log saying “GetSegmentVisibility: No display properties found for segment with ID artery”).
What if you do this instead?

display.SetSegmentVisibility(segmentation.GetSegmentation().GetSegmentIdBySegmentName(segment_id), False)

Thanks that did the trick! I must’ve mixed up the two.