Psychosocial factors have been found to profoundly impact mental health of older adults, but the main focus in the current literature has been on one particular aspect of these factors. This study aimed to identify latent classes of older adults based on four psychosocial factors (loneliness, social isolation, perceived social support, and social capital) and the transition of classes over 6 months. We also sought to assess the predictive role of changes in these classes in relation to depression, anxiety, and stress at 18-month follow-up. We analyzed longitudinal data from 581 community-dwelling older adults in Shanghai, China. The data were collected at baseline (T0), 6-month follow-up (T1) and 18-month follow-up (T2) between March 2021 and April 2023. Using latent class analysis, we identified three underlying classes (Social Connectors, Subjective Social Isolates, and Social Isolates) of the sample. We also established five transition categories from T0 to T1 (Social Connectors T0-T1, Subjective Social Isolates T0-T1, Social Isolates T0-T1, Good Transition, and Bad Transition) using latent transition analysis. Logistic regression was employed to examine the temporal relationships between these transition categories and subsequent symptoms of depression, anxiety and stress, adjusting for age, sex, education, marital status, family income level, sleep quality, health status and outcome variables at T0. Multivariable associations revealed that compared to older adults with persistent good social environment (Social Connectors T0-T1), those with persistent high levels of loneliness and social isolation and low levels of perceived social support and social capital (Social Isolates T0-T1), and those who shifted towards a poorer social environment (Bad Transition) were more likely to experience depression, anxiety and stress at T2. Sustained subjective social isolation (Subjective Social Isolates T0-T1) was associated with more severe depressive symptoms at T2. Our study indicated that adverse psychosocial environment worsened mental health in older adults. These findings highlight the importance of early identification of older individuals at long-term psychosocial risk and development of tailored interventions to improve their social environment and mental health.