I wrote a formatted and detailed answer here on my blog, which I cut and paste below the blog post link (losing html formatting).
There are 4 permutations of samatha and vipassana, the order in which they're developed.
The 3rd permutations is the ideal scenario, where both are developed in tandem.
The 4th permutation, neither are developed, at first. But then:
Puna caparaṃ, āvuso, bhikkhuno dhammuddhaccaviggahitaṃ mānasaṃ hoti.
Another monk’s mind is seized by restlessness to realize the teaching.
Hoti so, āvuso, samayo yaṃ taṃ cittaṃ ajjhattameva santiṭṭhati sannisīdati ekodi hoti samādhiyati.
But there comes a time when their mind is stilled internally; it settles, unifies, and becomes undistractify-&-lucidifyd in samādhi.
Tassa maggo sañjāyati.
The path is born in them.
So taṃ maggaṃ āsevati bhāveti bahulīkaroti.
They cultivate, develop, and make much of it.
To answer the OP questions, two key points need to be understood.
ekodi and samadhi is code phrase indicating second jhana or higher (see MN 20, MN 119, and several others).
Uddhacca is referring to the 5 hindrance's restlessnness.
vigggahitam means trying to the ascertain the meaning.
So the meditator, in trying to ascertain the meaning of Dhamma when under the influence of the hindrance of restlessness (4th of 5 hindrances), fails. In other words, he's not doing vipassana successfully because he has insufficient samatha.
But later on, he develops second jhana or higher as indicated by the ekodi and samadhi markers, fullfilling requisite amount of samatha (see SN 46.2, samatha is nutriment for samadhi). Therefore the uddhacca restlessness is no longer a problem, and his Dharma investigation succeeds, his vipassana succeeds because his samatha is good enough.
Since the 4 permutations already covered the samatha preceding vipassanna, then this 4th case is unlikely to be that, and more likely to be having initially no samatha and vipassana, and later samatha and vipassana in tandem.
Conclusion on AN 4.170
So when one considers all 4 permutations, and all 4 attain a path that leads to arahantship, it's clear that samatha and vipassana both need to be present to sufficient quality to succeed, it's just that through inherent weakness in individual meditators, some may mature in samatha first or vipassana first, and not the case that the Buddha recommended one develop samatha before vipassana, or vice versa.
Also, if you study the formula for the four jhanas carefully, and the satipatthana formula carefully, you'll see that 3rd jhana (any of 4 jhanas would fulfill samatha) includes both sati and sampajano (equivalent to pañña and vipassana). And within the satipatthana formula, which also includes sati and sampajano factors, the "vineyya loke abhijja domanassa" is a reference to one having subdued the 5 hindrances, the tough part of samatha training, and putting you right in the doorway of first jhana (which would satisfy samatha). In other words, satipatthana is embedded within jhana, and jhana is embedded within satipatthana. That's the Buddha saying samatha and vipassana is ideally developed in tanndem ( 4 Jhānas🌕 ≈ 4 Satipaṭṭhāna🐘 ).