diff --git a/src/models/room.ts b/src/models/room.ts index 399f98614..ca36f67ea 100644 --- a/src/models/room.ts +++ b/src/models/room.ts @@ -2028,8 +2028,11 @@ export class Room extends ReadReceipt { }; } - const parentEventId = event.getAssociatedId()!; - const parentEvent = this.findEventById(parentEventId) ?? events?.find((e) => e.getId() === parentEventId); + const parentEventId = event.getAssociatedId(); + let parentEvent: MatrixEvent | undefined; + if (parentEventId) { + parentEvent = this.findEventById(parentEventId) ?? events?.find((e) => e.getId() === parentEventId); + } // Treat relations and redactions as extensions of their parents so evaluate parentEvent instead if (parentEvent && (event.isRelation() || event.isRedaction())) {