Get or create the label before you touch any threads
GmailApp.getUserLabelByName returns null when the label does not exist yet — it does not create it for you, and addLabel will throw if you hand it null. The one-liner fix is the short-circuit: getUserLabelByName(LABEL_NAME) || createUserLabel(LABEL_NAME). The first time the script runs, the label is created and returned. Every subsequent run finds it and skips creation. I keep this pattern in a utils file shared across all my Gmail scripts because forgetting it produces a cryptic 'Cannot call method addLabel of null' error that wastes ten minutes the first time you see it.
Nested label names use a forward slash: 'Acme/Invoices' creates an Invoices sublabel under Acme. If the parent Acme label does not exist yet, createUserLabel creates the full path in one call.