How to correctly do a nested test (t-test, rank-sum, etc) Let's say there are two groups of participants. Each group is randomly split into control subgroup A and task subgroup B. For each of the 4 cases some random variable $x$ is measured, whose mean is denoted by $\mu$. I would like to perform 3 tests:

*

*$H_0 : \mu_{A, Group1} = \mu_{B, Group1}$

*$H_0 : \mu_{A, Group2} = \mu_{B, Group2}$

*$H_0 : \mu_{Group1} = \mu_{Group2}$ regardless of subgroups

I sketch the tests below

Question: What is the correct way to perform these tests? If I perform 3 independent t-tests, is it fair to apply Bonferroni correction to their p-values, or must I do a more sophisticated multiple comparisons correction. If making independent tests is not a robust procedure, what is? I want to do all 3 tests, so as far as I understand I don't want two-way ANOVA.

As you correctly point out, the issue here is largely a matter of dealing with the problem of multiple comparisons.  In the case of nested tests, this matter is complicated by the fact that the hypotheses for the tests have direct logical implications to each other, so you are right to think that a standard application of Bonferroni's method would be problematic.
The method that is usually applied here is to first perform an over-arching test to see if there is any evidence of a difference across either subgroup.  That test is not listed in your post, but it would test the hypotheses:
$$H_0: \boldsymbol{\mu}_A = \boldsymbol{\mu}_B
\quad \quad \quad 
H_A: \boldsymbol{\mu}_A \neq \boldsymbol{\mu}_B,$$
where these vector parameters each contain the mean parameters for both subgroups.  If there is no evidence of a difference then that ends the matter and the smaller tests are not performed.  If there is evidence of a difference then we may then proceed to do the more specific tests 1-2.  In a regression context, the overall test would be done using an F-test and the smaller tests would be done using t-tests.
