Drupal 8 9 10 Views hide admin-only column

For the fairly pedestrian purpose of making sure the operations column isn’t showing and empty, for which the ‘hide empty column’ option already built into Views is buggy (because Drupal still outputs the scaffolding of the list of links even though there are none), it would be a helpful workaround to simply be able to tell Views when to not show an entire column to people who do not have a given role. This might also be useful for admin-only data (or information only relevant to administrators, even if the data itself is public).

A fine unsolicited forum post with some code to do this:

Hide/Remove a column in a table view | Drupal.org

Five-year-old question with no answer:

8 - How do I hide a table column in a view depending on role? - Drupal Answers

(It does have a comment mentioning the same, i think, template approach as in that forum post.)

A self-answered question with a bad answer, how to limit the column or fields to only a sepecafic role in views Drupal? - Stack Overflow

A surprising number of modules offer this capability to turn columns off to the visitor:

Views Fields On/Off | Drupal.org

(That module helpfully lists two similar modules, Views Dynamic Fields and Views Adjustable Table, and there was yet another that stayed Drupal-7 only called Views Column Control.)

Any could be a good basis for a module that gives this control to administrators— i feel favorable to Views Fields On/Off because it lists its alternatives!

This issue might help see the parts of code we need to work with to fix

“Hide empty column” only hides the header [#2621874] | Drupal.org