How do Twig filters interact with concatenated strings and shorthand "if-else" ( `var ? true : false` ) strings? If I am outputting content like this:
{{ entry.maxWidth|length ? entry.maxWidth ~ 'px' : 'unset' }}

...and I want to apply the |raw filter to the output (nevermind if it makes sense in this case; it's just an example), where do I put it?
Do I go overboard, applying the desired filter to each bit of string, like this?
{{ entry.maxWidth|length ? 'max-width: '|raw ~ entry.maxWidth ~ 'px;'|raw : 'max-width: unset;'|raw }}

Is it applied after any string concatenation (~) is done?
{{ entry.maxWidth|length ? 'max-width: ' ~ entry.maxWidth ~ 'px;'|raw : 'max-width: unset;'|raw }}

Or is once per set of double-brackets ({{ ... }}) sufficient?
{{ entry.maxWidth|length ? 'max-width: '~ entry.maxWidth ~ 'px;' : 'max-width: unset;'|raw }}
You are asking about Twig's operator precedence:

The operator precedence is as follows, with the lowest-precedence operators listed first: ?: (ternary operator), b-and, b-xor, b-or, or, and, ==, !=, &lt;=&gt;, &lt;, &gt;, &gt;=, &lt;=, in, matches, starts with, ends with, .., +, -, ~, *, /, //, %, is (tests), **, ??, | (filters), [], and .:

| is higher precedence than ~, so 'this' ~ 'that' | raw will evaluate as 'this' ~ ('that' | raw). If you want ('this' ~ 'that') | raw then () is the way to go.
Personally, I would use () to disambiguate in both cases.