diff --git a/app/Services/Queue/QueueClient.php b/app/Services/Queue/QueueClient.php index 985f697..296b92c 100644 --- a/app/Services/Queue/QueueClient.php +++ b/app/Services/Queue/QueueClient.php @@ -298,13 +298,19 @@ class QueueClient try { $this->ensureBranch($owner, ['name' => $branchName]); } catch (RequestException $e) { - // Free Queue plans may already be at branch cap — continue if branch already exists. + // Free Queue plans may already be at branch cap — continue if a branch can be resolved. if ($e->response?->status() !== 422) { throw $e; } - $existing = collect($this->branches($owner))->first( + $branches = collect($this->branches($owner)); + $existing = $branches->first( fn ($b) => strcasecmp((string) ($b['name'] ?? ''), $branchName) === 0 ); + if (! $existing && $branches->count() === 1) { + // Single-location Queue orgs often use a different default name (e.g. "Main Branch"). + $existing = $branches->first(); + $branchName = (string) ($existing['name'] ?? $branchName); + } if (! $existing) { throw $e; }