When nesting $if statements (or $exclude), you must number the $if and its matching $endif so the reporting engine can pair the $if with the appropriate $endif. For example:
$if1 UseCases Exist ... $if2 Notes Exist ... $endif2 ... $endif1
The same is true for nested repeats, but only when the nested repeat is showing the same type of items that the outer repeat is showing. For example:
$repeatRequirements1SortID where IsTopLevel = True (* see note below)
Since both the inner repeat and outer repeat are showing Requirements, numbering is needed. However if the inner repeat instead showed Notes, no numbering would be needed.
* IsTopLevel is only supported for CaseComplete 2011 and later. Alternative syntax is available for earlier versions.