Here is an example with three traces in three different legends "legend", "legend2" and "legend3". "legend3" is set to "visible": false and for some reason "legend" is then also hidden. When setting legend3.visible = true, both "legend" and "legend3" become visible.
(As an alternative solution I can set "showlegend": false on the trace attached to "legend3" instead of setting "visible": false on "legend3".)
https://codepen.io/toffi-fee/pen/vELBZpK
Expected:
Actual:
