Strangely I did read today even he played for nothing they would breach the guidelines. Struggling with the logic of that one to be honest
It's really quite simple :)
The Spanish League sets the salary limit (1st team, 2nd team, and coaches) for each club in advance of the season based on its projected income and taking into account its debts. The salary limit also includes net transfer spend.
This enabled all La Liga clubs, apart from Valencia, to operate at a profit prior to Covid.
Going into Covid Barcelona's wage bill was enormous, over 600m euros a year, 133m of which was Messi's gross pay.
With the combined effects of Covid reductions in revenue and Barcelona's ludicrous transfer policy their wage bill had to be halved last season. For this season it's reported to have to be somewhere between 160-200m euros, so less than a third of what it was just two seasons ago. Most, if not all, their players have taken a salary hit.
However, even with those reductions they are still substantially over the limit with their currently contracted players - in fact some of those may not be able to be registered to play either, even though the club has to pay them. They have to get rid of players and generate some transfer income just to get themselves inside the limit.
Had Messi been under contract the situation may have been very different, but his contracted ended on 30th June. To re-sign him therefore meant he would be treated as a new signing.
They can't register any new signings, including Depay or Aguero, until they're under the salary limit.
A "normal" club could get around this by the introduction of new capital from the owner. However, 4 clubs in Spain are members clubs and don't have an owner - these are Real Madrid, Athletic Club, Osasuna and Barcelona.
So.... even if he agreed to play for nothing (and that was legal), he still could not do so.