title: Google Sheets Apps Script not hiding tabs
body: <p>So, the goal is to take the emails from the 'Emails' tab (which contains 8 different lists), put them into an array. Then, depending on who is the active user, hide and show specific tabs. I have looked into many different methods of this (I'm doing it for privacy reasons) and this seems to be the only reasonable way of doing it. Each user needs access to edit the tabs that they have access to.</p>
  <p>I also have a 'Troubleshooting' tab that I'm kind of using as a settings tab. This contains a list of the different tab names and which list gets access to it. (each tab will only have one list it corresponds to)</p>
  <p>My issue is that it is not hiding any of the tabs.</p>
  <ul>
  <li><code>updateHiddenSheets()</code> has a trigger 'on open'</li>
  <li><code>validUsers()</code> has a trigger 'on edit'</li>
  </ul>
  <p>Both run with no errors, so I'm not sure where the issue is here.</p>
  <pre><code>/*Things to Do:
      - make the tabs sorted by ward/stakepeople
      - have tab names automatically update in this code .getSheetByName()
      - 
  */
  var stakePeople = [];
  var ward1 = [];
  var ward2 = [];
  var ward3 = [];
  var ward4 = [];
  var ward5 = [];
  var ward6 = [];
  var ward7 = [];
  
  function validUsers() {
    var activeSheetName = SpreadsheetApp.getActiveSheet().getSheetName();
    if(activeSheetName = 'Emails'){
      var numEmails = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Emails').getRange(52,2).getValue();
  
  
      var emailsList = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Emails').getRange(2,1,numEmails,8).getValues();
      var numEmailsAct = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Emails').getRange(51,1,1,8).getValues();
  
      for(i=0; i&lt;=numEmailsAct[0];i++) {
        ward1.push(emailsList[i][0]);
      }
      for(i=1; i&lt;=numEmailsAct[1];i++) {
          ward2[i] = emailsList[i][1];
      }
      for(i=1; i&lt;=numEmailsAct[2];i++) {
          ward3[i] = emailsList[i][2];
      }
      for(i=1; i&lt;=numEmailsAct[3];i++) {
          ward4[i] = emailsList[i][3];
      }
      for(i=1; i&lt;=numEmailsAct[4];i++) {
          ward5[i] = emailsList[i][4];
      }
      for(i=1; i&lt;=numEmailsAct[5];i++) {
          ward6[i] = emailsList[i][5];
      }
      for(i=1; i&lt;=numEmailsAct[6];i++) {
          ward7[i] = emailsList[i][6];
      }
      for(i=1; i&lt;=numEmailsAct[7];i++) {
          stakePeople[i] = emailsList[i][7];
      }
    }
  }
  
  function updateHiddenSheets(){
    var currentUserEmail = Session.getActiveUser().getEmail()
    var wardSheetNames = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Troubleshooting').getRange(24,3,19,2).getValues();
  
    var ward1B = false;
    var ward2B = false;
    var ward3B = false;
    var ward4B = false;
    var ward5B = false;
    var ward6B = false;
    var ward7B = false;
    var stakePeopleB = false;
  
    if (ward1.includes(currentUserEmail)) { 
      ward1B = true;
    } 
    if (ward2.includes(currentUserEmail)) { 
      ward2B = true;
    } 
    if (ward3.includes(currentUserEmail)) { 
      ward3B = true;
    } 
    if (ward4.includes(currentUserEmail)) { 
      ward4B = true;
    } 
    if (ward5.includes(currentUserEmail)) { 
      ward5B = true;
    } 
    if (ward6.includes(currentUserEmail)) { 
      ward6B = true;
    } 
    if (ward7.includes(currentUserEmail)) { 
      ward7B = true;
    } 
    if (stakePeople.includes(currentUserEmail)) {
      stakePeopleB = true;
    }
  
    if(ward1B){
      for(i=0;i&lt;19;i++){
        if(wardSheetNames[i][1]=&quot;1&quot;){
          SpreadsheetApp.getActiveSpreadsheet().getSheetByName(wardSheetNames[i][0]).showSheet(); 
        }
      }
    }
    if(ward2B){
      for(i=0;i&lt;19;i++){
        if(wardSheetNames[i][1]=&quot;2&quot;){
          SpreadsheetApp.getActiveSpreadsheet().getSheetByName(wardSheetNames[i][0]).showSheet(); 
        }
      }
    }
    if(ward3B){
      for(i=0;i&lt;19;i++){
        if(wardSheetNames[i][1]=&quot;3&quot;){
          SpreadsheetApp.getActiveSpreadsheet().getSheetByName(wardSheetNames[i][0]).showSheet(); 
        }
      }
    }
    if(ward4B){
      for(i=0;i&lt;19;i++){
        if(wardSheetNames[i][1]=&quot;4&quot;){
          SpreadsheetApp.getActiveSpreadsheet().getSheetByName(wardSheetNames[i][0]).showSheet(); 
        }
      }
    }
    if(ward5B){
      for(i=0;i&lt;19;i++){
        if(wardSheetNames[i][1]=&quot;5&quot;){
          SpreadsheetApp.getActiveSpreadsheet().getSheetByName(wardSheetNames[i][0]).showSheet(); 
        }
      }
    }
    if(ward6B){
      for(i=0;i&lt;19;i++){
        if(wardSheetNames[i][1]=&quot;6&quot;){
          SpreadsheetApp.getActiveSpreadsheet().getSheetByName(wardSheetNames[i][0]).showSheet(); 
        }
      }
    }
    if(ward7B){
      for(i=0;i&lt;19;i++){
        if(wardSheetNames[i][1]=&quot;7&quot;){
          SpreadsheetApp.getActiveSpreadsheet().getSheetByName(wardSheetNames[i][0]).showSheet(); 
        }
      }
    }
    if(stakePeopleB){
      for(i=0;i&lt;19;i++){
        if(wardSheetNames[i][1]=&quot;Stake&quot;){
          SpreadsheetApp.getActiveSpreadsheet().getSheetByName(wardSheetNames[i][0]).showSheet(); 
        }
      }
    }
    for(i=0;i&lt;19;i++){
      if(wardSheetNames[i][1]=&quot;All&quot;){
        SpreadsheetApp.getActiveSpreadsheet().getSheetByName(wardSheetNames[i][0]).showSheet(); 
      }
    }
  } 
  </code></pre>