(For more on Masechet Sofrim, one of the "smaller tractates", additions to the Talmud- https://en.wikipedia.org/wiki/Soferim_(Talmud)).
מסכתות קטנות מסכת סופרים פרק יד
פוחח, הנראין כרעיו, או בגדיו פרומים, או מי שראשו מגולה, פורס על שמע, ויש אומרים בכרעיו נראין, או בגדיו פרומים, פורס על שמע, אבל בראשו מגולה אינו רשאי להוציא הזכרה מפיו; ובין כך ובין כך מתרגם, אבל אינו קורא בתורה, ואינו עובר לפני התיבה, ואינו נושא את כפיו.
What is pocheach (a condition in which a person is able to say shema but not to read Torah)? One whose thighs are visible, or his garments are unraveling, or his head is bare,may recite shema. And there are those who say that one whose knees are visible or his garments are unraveling may recite the shema, however one whose head is uncovered is not permitted to mention the name of Gd. And any of these may translate but they may not read Torah, and they may not lead services [literally: descend before the ark], and they may not give the priestly benediction.
We often don't think about modesty for prayer as a gender-neutral or masculine concern, but in this context, where the assumption is that men are the ones who read Torah, lead services, etc, it is clear that we are talking about minimum standards of male modesty.
In this context, there are three "levels" of modesty- the first, where one may perform any public ritual function, such as leading services and reading Torah. This requires covered thighs and intact clothing.
In the second level, one may pray privately, but not lead services or be involved in most public ritual. This category is the explicit topic of this text, and includes such intermediate sorts of body-coverage such as having thighs visible or clothing that is unraveling or presumably has holes. A second opinion includes even bare knees.
In either of these categories, one may still be a translator for the Torah reading [a practice that most of the Jewish world has abandoned, perhaps with the availability of printed texts, but the Yemenite community still maintains. The practice is to translate each verse into Aramaic, one at a time, after they are read from the Torah.] So there are still some public roles that are acceptable while not fully meticulously covered.
In the third, one may not even pray privately, especially according to the second opinion given, that forbids even mentioning G-d with an uncovered head.
This text is relevant to our questions because there is a disagreement as to what category being bare headed falls into. The first opinion puts it into the second level- pocheach, while the second opinion puts it into the third level, where one may not even pray privately.
This is interesting because this is a description of head covering as part of a concern for public appropriateness or appearing respectable. And yet the second opinion implies that it is actually about private respect for G-d, and relevant in all situations, even unconnected to how one appears to other people. The two opinions have different visions of what head covering (for men at least) is about- is it devotional or about public respectability?
Depending on which way we go, we can derive different decisions about the importance of covering now, where it is of less concern for public respectability, and where women as well as men may be interested in covering as a devotional practice. If it is about public respectability, we may want to be not only lenient but also find that there's less significance to wanting to do so. If it is about the ability to appropriately pray, then we should encourage it for as many Jews as we can, in a wider range of contexts.