The absolute potentials on the plates of a capacitor (or the terminals of a battery) are undefined and commonly described as floating until one plate or terminal is connected to some stable reference such as Earth. What matters is the potential difference (PD) across the plates of the capacitor or between the terminals of the battery. This PD is fixed until the capacitor or battery is connected in a circuit which allows current to flow (either DC or AC or transient current).
Initially all 3 capacitors are charged. The 2 plates of each carry a certain amount of charge $\pm q_i$ where $q_i=C_i V_i$ and $i=1, 2, 3$.
When the +ve plates are connected to each other at point A, but before the -ve plates are Earthed, nothing happens! There is no flow of charge! This is because +ve charge cannot leave the +ve plate of any capacitor (even when there is somewhere it can flow to) unless the same amount of -ve charge can leave the -ve plate. The -ve plates are not connected to anything, so -ve charge cannot leave those plates, so +ve charge can't leave the +ve plates either. Even if A is connected to Earth, no charge flows to or from the +ve plates via A, because there is no way for the charge on the -ve plates to change.
(This situation is similar to batteries being connected via their +ve terminals. No current flows until the -ve terminals are connected to something. Even if the +ve terminals are connected to ground this makes no difference : there is nowhere for charge on the -ve terminals to flow to, so there is no current.)
It is only when the -ve plates are connected to Earth that -ve charge can flow (for a short time) to/from them, at the same time as the same amount of +ve charge flows to/from the +ve plates.
The charge on the +ve plates of the 3 capacitors is redistributed in such a way that (i) the total amount of +ve charge remains the same as before, and (ii) the (unknown) potential difference $V_i'$ across each capacitor is now the same - because the +ve plates are all connected (via A) and the -ve plates are all connected (via Earth). The new charges on the +ve (and -ve) plates are related by $q_i'=C_i V_i'$ where $V_1'=V_2'=V_3'$.
When the battery and 4th capacitor $C_4$ are connected, but before the switch is closed, again nothing happens! Although the battery could pump +ve charge from $C_4$ to point A (leaving -ve charge on the left plate of $C_4$), there is nowhere for +ve charge to reach the right plate to maintain the balance between +ve and -ve charge.
So before the switch is closed nothing changes. The PDs across and the charges on capacitors $C_1, C_2, C_3$ don't change, the potential of point A does not change. The only thing that happens is that the potential at $C_4$ becomes $20V$ below that at A. (The PD across $C_4$ remains zero.)
Now the switch is closed. Some charge $+q_4''$ flows from Earth onto the right plate of $C_4$ and equal charge $+q_4''$ flows from the left plate of $C_4$ (leaving it charged $-q_4''$) through the battery to point A. From there it is redistributed between $C_1, C_2, C_3$. Meanwhile a total -ve charge of $-q_4''$ flows from Earth to the -ve plates of $C_1, C_2, C_3$ to match the increase $+q_4''$ provided by the battery.
The PD across $C_1,C_2, C_3$ is no longer $V_1'= V_2'=V_3'$. It has increased to $V_1''=V_2''=V_3''=V_4''+20V$. Also, the PD across $C_4$ is no longer zero. It is now related to $q_4$ by $q_4''=C_4 V_4''$.
In summary :
The initial charge on each capacitor is related to the initial PD across each by $q_i=C_i V_i$.
After the capacitors are connected at A, but before the switch is closed, the charges across each capacitor are related by $q_1'+q_2'+q_3'=q_1+q_2+q_3$ and $V_1'=V_2'=V_3'$ where again $q_i'=C_i V_i'$.
After the switch is closed the final PDs across the capacitors are related to each other by $V_1''=V_2''=V_3''=V_4''+20V$. And they are related to the final charges on each capacitor by $q_i''=C_i V_i''$ and $q_1''+q_2''+q_3''=q_1'+q_2'+q_3'+q_4''$.
The only part of Step 2 which is useful is that $q_1'+q_2'+q_3'=q_1+q_2+q_3$. This can be substituted directly into Step 3 to give $q_1''+q_2''+q_3''=q_1+q_2+q_3+q_4''$. It is not necessary to calculate the values of $q_i'$ or $V_i'$ in Step 2.