The Idea in Brief
The inverted nuns (“isolated nun,” or nun hafukkah) in the Masoretic Text of the Aleppo Codex and those found in the Leningrad Codex are not consistent in Psalm 107. In the former, the inverted nuns are aligned to verses 23-28 and 40, and in the latter, the inverted nuns are aligned to verses 21-26 and 40.
In other words, Psalm 107 presents the picture of the wilderness wanderings of the Israelites, when (according to the Aleppo Codex) verses 23-28 and 40 are taken as parenthetical. If and when the inverted nuns are otherwise ignored (and the psalm is simply read as a normal whole) then the Psalm appears as a four-portion picture summary of the Lord delivering from distress: that is, lost travelers in the dark arriving to their destination (vv. 4-9); prisoners released from confinement (vv.10-16); the hopeless sick restored to good health (vv.17-22); and sailors lost at sea delivered to port (vv.23-32).
Therefore the prevalence of the use of the Leningrad Codex by Western scholars (per the Biblia Hebraica Stuttgartensia) has made this nuance difficult to see, since there is no reference in the footnotes of the BHS to indicate this variant reading (and interpretation) as evident from the Codex Aleppo.
Discussion
The Biblia Hebraica Stuttgartensia is based on the Leningrad Codex, and is the oldest dated manuscript of the complete Hebrew Bible. However, the Aleppo Codex is the oldest (next largest) dated manuscript of the incomplete (Masoretic) Hebrew Bible. In other words, the latter predates the former by several decades according to sources cited on the respective Wikipedia sites.
Thus there are slight differences between both Masoretic texts. The inverted nuns are one example -- according to the page in the Leningrad Codex, the inverted nuns cover verses 21-26 and 40. However, according to the page in the Aleppo Codex, the inverted nuns cover verses 23-28 and 40.
If one assumes that the inverted nuns have parenthetical value, then reading the text of Psalm 107 does not make apparent sense in the Codex Leningrad. However, if one reads the same psalm in the Codex Aleppo, then the psalm presents the picture of the wilderness wanderings of the Israelites, whom the Lord delivered into the Promised Land. Thus the Masoretes of the Codex Aleppo annotated their manuscript to provide the reader an interpretation of the psalm sans the references to sailors and sea-faring (and wayward princes).
Thus when reading Psalm 107 with the respective verses in parentheses (according to the inverted nuns as noted in the Codex Aleppo), the reader would read the Psalm as noted here. Please note that the words highlighted in blue in vv.29-30 would reflect a more nuanced but yet literal translation.
Conclusion
These differences between the two Masoretic codices do not imply errors in transmission. The editors of the Masoretic texts in Aleppo, Syria, however saw some nuance in Psalm 107 that hearkened to the wilderness wanderings, where the inverted nun in the Masoretic texts had first appeared in (Numbers 10:35-36). That is, by using inverted nuns in Psalm 107, the Masorete editors in Aleppo were making an apparent allusion to the wilderness wanderings and the deliverance of the Lord to bring the Israelites into the Promises Land.
The suggested "parenthetical" Psalm 107 would therefore align to the Lord delivering from distress and bringing his people to rest, which is the Promised Land. Furthermore, the absence of any notation in the margins (Massorah Parva) or at the foot or end of the book (Massorah Magna) in any Masoretic codex contributed to confusion, since the original Masorete editors who made this observation must have assumed that any reader of the Hebrew texts would "get it" without any clarifying explanation. That is, if the Codex Leningrad appeared later by several decades, and these copyists were borrowing from the the Codex Aleppo (or other parallel Vorlagen extant at the time), and saw the inverted nuns (with no apparent explanation in any available Massorot), then the error of annotating verses 21-26 with the inverted nuns (instead of verses 23-28) may have occurred in the Codex Leningrad because the copyists of that text did not "get it."