HTTPSRedirect String Comparison does not match

1.I tried to change the name of the string to 'flag' but received an error messege "'flag' was not declared in scope". Why can't I change this to anything other than 'str'?

You could have, if you change the variable declaration and every use of the variable name.

if (client->GET(url3, host)){
   ++connect_count;
 //assign the output string of the readD3 Google appps function to a string called 'str'
   String paid= client->getResponseBody();
  
  }

The variable named paid exists until the } is encountered, which happens REALLY, REALLY soon after it is assigned a value. You might as well not be calling the GET() method with url3.

  String paidBy = "Nobody";
  if (client->GET(url3, host))
  {
     ++connect_count;
     paidBy = client->getResponseBody();
  }
  Serial.print("Who paid for my beer?");
  Serial.print(paidBy);
  Serial.println(" paid for the beer!");

  if(paidBy == "Nobody")
  {
     // Hey, you owe me $8.00 for the beer
  }

Would be the proper way to write that snippet.

3.Why do I need to get the data again using 'getresponseBody();' if it was declared in the 'if' statement just above it?

Specifically, which line numbers are you referring to?

The previous info may give you a clue.