diff --git a/templates/repo/graph/commits.tmpl b/templates/repo/graph/commits.tmpl
index 8f3260ba50..d08539ebeb 100644
--- a/templates/repo/graph/commits.tmpl
+++ b/templates/repo/graph/commits.tmpl
@@ -33,14 +33,8 @@
{{range $commit.Refs}}
{{$refGroup := .RefGroup}}
{{if eq $refGroup "pull"}}
- {{if $.HidePRRefs}}
- {{if (containGeneric $.SelectedBranches .Name) }}
-
- {{svg "octicon-git-pull-request" 16 "mr-2"}}#{{.ShortName}}
-
- {{end}}
- {{else}}
-
+ {{if or (not $.HidePRRefs) (containGeneric $.SelectedBranches .Name)}}
+
{{svg "octicon-git-pull-request" 16 "mr-2"}}#{{.ShortName}}
{{end}}